我现在有一个java类,但是我需要不同的构造方法来传递参数,但是构造方法的参数个数和参数类型是一样的,这样构造方法该怎么写?
例:
public class User{
private int id;
private String userName;
private String passWord;
private String address;
此处省略...get...set...
public User(String userName,String passWord){
this.userName=userName;
this.passWord=passWord;
}
public User(String userName,String address){
this.userName=userName;
this.address=address;
}
}
这种情况该怎么办?请各位吧友不吝赐教
例:
public class User{
private int id;
private String userName;
private String passWord;
private String address;
此处省略...get...set...
public User(String userName,String passWord){
this.userName=userName;
this.passWord=passWord;
}
public User(String userName,String address){
this.userName=userName;
this.address=address;
}
}
这种情况该怎么办?请各位吧友不吝赐教