58,452
社区成员




for (student t : list) {
System.out.println(t.name + " " + t.number + " " + t.score);
}
import java.util.*;
class student {
String name;
int number;
float score;
public student(String name, int number, float score) {
this.name = name;
this.number = number;
this.score = score;
}
}
public class A {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedList<student> list = new LinkedList<student>();
student stu1 = new student("赵好明", 9012, 80.0f);
student stu2 = new student("钱小青", 9013, 90.0f);
student stu3 = new student("孙力枚", 9014, 78.0f);
student stu4 = new student("周左右", 9015, 55.0f);
list.add(stu1);
list.add(stu2);
list.add(stu3);
list.add(stu4);
Iterator<student> it = list.iterator();
while (it.hasNext()) {
student t = it.next();
System.out.println(t.name + " " + t.number + " " + t.score);
}
}
}
for(student s:list){
System.out.println(s.name+" "+s.number+" "+s.score);
}
Iterator<student> it = list.iterator();
while (it.hasNext()) {
student t = (student)it.next();
System.out.println(t.name+" "+t.number+" "+t.score);
}