public static void main(String[] args) {
ArrayList<Person> list = new ArrayList<>();
list.add(new Person("德玛血压",60));
list.add(new Person("德邦莽夫",23));
list.add(new Person("皇子小三",28));
list.add(new Person("剑圣求败",53));
list.add(new Person("诺克掉渣",30));
Person p =new Person();
ListIterator<Person> it = list.listIterator();
int max = list.get(0).getAge();
p = list.get(0);
for (Person person : list) {
if (max < person.getAge()) {
max =person.getAge() ;
p = person;
}
}
System.out.println(p);
}
}
|