import java.util.ArrayList;
import java.util.List;
class Student {
private String name;
public Student() {
super();
}
public Student(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Student [name=" + name + "]";
}
}
public class Homework14_3 {
public static void main(String[] args) {
List list = new ArrayList<>();
list.add(new Student("张三"));
list.add(new Student("李四"));
list.add(new Student("王五"));
System.out.println(list);
}
} |