1 ? List<Student> list = new ArrayList; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//student 為定義的一個student類含有name,age屬性2 ? for(Iterator<Student> i = list.iterator() ; i.hasNext(); ){3 ? Student s = i.next();4 ? System.out.println("name:"+s.name+" ? ?"+"age:"+s.age);? ?}為什么不能把第三行改成String s = i.next().name;int age = i.next().age;
添加回答
舉報
0/150
提交
取消
