构造方法的重载
范例1
class Student {
public Student() {
System.out.println(“无参的构造方法”);
}
public Student(String name) {
System.out.println(“一个参数的构造方法”);
}
public Student(String name, int age) {
System.out.println(“两个参数的构造方法”);
}
}
范例二
public class Example05 {
public static void main(String[] args) {
Student s1 = new Student();
Student s2 = new Student(“Rose”);
Student s3 = new Student(“Rose”, 23);
}
}