package demo;
import java.util.ArrayList;
import java.util.List;
class Person {
private String username;
private int age;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Person(String username, int age) {
super();
this.username = username;
this.age = age;
}
@Override
public String toString() {
return "Person [username=" + username + ", age=" + age + "]";
}
}
public class Test {
public static void printList(List list) {
for(int i=0;i
运行结果
638559109
1287160904
1710537297
636768290
1253637029
Person [username=c, age=14]
----------------------------------
Person [username=a, age=12]
----------------------------------
Person [username=b, age=13]
Person [username=d, age=15]
Person [username=e, age=16]
----------------------------------