构造方法的重载

构造方法的重载跟方法的重载差不多,看看代码就可以了,没有什么过多的解释

public class Uer {
int id;
String name;
String pwd;

public Uer() {

}

public Uer(int id, String name) {
this.id = id;
this.name = name;

}

public Uer(int id, String name, String pwd) {
this.id = id;
this.name = name;
this.pwd = pwd;
}

public static void main(String[] args) {
Uer u1 = new Uer();
Uer u2 = new Uer(101, "聂政");
Uer u3 = new Uer(100, "聂政", "123456");
}
}

上一篇:js密码强度判断


下一篇:正课复习2