Java中for循环遍历List的两种方法
常用的方法:
List<Person> people = ...;
for (int 1=0;i<people.size();i++){
people.get(i).setEat("吃饭");
}
相当于:
List<Person> people = ...;
for (Person person : people){
person.setEat("吃饭");
}
更多推荐
Java初级教程 for循环遍历List的两种方法
发布评论