一:为构造方法的参数设置值
首先写两个类:
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Student {
private int age;
private String name;
private Date birthday;
private int [] scores;
private List<String> names;
private Set<String> id;
private Map<String, Date> birthdays;
public Student(int age, String name) {
this.age = age;
this.name = name;
}
public Student(Date birthday) {
this.birthday = birthday;
System.out.println(birthday);
}
public Student(int [] scores) {
this.scores = scores;
for (int i : scores) {
System.out.println(i);
}
System.out.println("数组");
}
public Student(List<String> names) {
this.names = names;
for (String string : names) {
System.out.println(string);
}
System.out.println("list集合");
}
public Student(Set<String> id) {
this.id = id;
for (String string : id) {
S