其他分享
首页 > 其他分享> > example_3(实例化同名对象)

example_3(实例化同名对象)

作者:互联网

实例化同名对象时赋值

public class User {
    int id;
    String name;
    String pwd;
    public User(){}

    public User(int id ,String name){
        super();
        this.id=id;
        this.name=name;
    }

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

    public static void main(String[] args){
        User u1=new User();
        User u2=new User(10,"ojb");
        User u3=new User(100,"100号","123456");
    }
}

 

标签:name,同名,example,public,pwd,实例,User,id,String
来源: https://www.cnblogs.com/ojbtospark/p/16034206.html