造人

package com.aila;
public class La {
  public int id;
  public String name;
  public int age;
  public String city;
  public void printX()
  {
    System.out.println("我的名字叫=" + name + ",代号是 =" + id + ", 年龄是=" + age + ", 所在城市=" + city);
  }

  public La()
  {
    System.out.println("这是没有参数的方法,用此语句证明执行过!");
  }

  public La(int id,String name,int age,String city) {
    this.name=name;
    this.id=id;
    this.age=age;
    this.city=city;
  }
}
 
package com.aila;
public class Ai {
  public static void main(String[] args)
  {
  
    La aila1=new La();
    aila1.name="xiaohan1";
    aila1.id=001;
    aila1.age=18;
    aila1.city="秋叶原";

    La aila2=new La();
    aila2.name="xiaohan2";
    aila2.id=002;
    aila2.age=18;
    aila2.city="秋叶原";

    La aila3=new La();
    aila3.name="xiaohan3";
    aila3.id=002;
    aila3.age=18;
    aila3.city="秋叶原";

    aila1.printX();
    aila2.printX();
    aila3.printX();

 

  }
}

 

posted @ 2017-12-11 12:46  黄浩然  阅读(228)  评论(0编辑  收藏  举报