1、for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
2、List list = new HashList();
Iterator it = list.iterator();
while(it.hasNext()){
list.next();//返回值是object
}
for(int i = 0;i < list.size();i++){
list.get(i);//返回值是object
}
3、for(Object o:list){
System.out.println(o);
}
4、for (int i = 0; i < list.size(); i++) {
javabean jb= (javabean)list.get(i);
System.out.println(jb.getxxx());
System.out.println(jb.getxxxxx());
}
5、Iterator iterator = list.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
6、依次输出Person对象的p_name属性:
Iterator iterator = list.iterator();
while(iterator.hasNext())
{
person = (Person)iterator.next();
System.out.println(person.getP_name());
}
7、jdk1.5以后可以这样写了:
如List <Person> list ;
可以
for(Person p : list){
System.out.println(p.getXXX());
}
8、for(int i=0;i <list.size();i++){
list.get(i)//获得数据
}
9、for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
10、jdk1.5以后可以这样写了:
如List <Person> list ;
可以
for(Person p : list){
System.out.println(p.getXXX());
}
11、jdk1.5以后可以这样写了:
如List <Person> list ;
可以
for(Person p : list){
System.out.println(p.getXXX());
}
12、for (int i = 0; i < list.size(); i++) {
javabean obj= (javabean)list.get(i);
System.out.println(obj.getXxx());
}
用FOREACH循环