简单题不会,有一个Human类,有两个Human构造器 Human(String name,int age)和Human(String name,int age,int tel) 在三个参数的构造器中如何调用两个参数的构造器,生成此类的两个实例

解决方案 »

  1.   

    Human h1=new Human("jack",21);
    Human h2=new Human("jack",21,23545);
      

  2.   

    public class Human{  private String name;
      private int age;
      private int tel;  public Human(String name,int age){
        this.name = name;
        this.age = age;
      }
      
      public Human(String name,int age,int tel){
        this(name,age);
        this.tel = tel;
      }  //getter and setter}
      

  3.   

    Human(String name,int age,int tel){
            this(name,age);
        }
      

  4.   


      public Human(String name,int age,int tel){
        this(name,age);
        this.tel = tel;
      }
    一楼的正确