zuoye2016.3.7

 package org.zuoye .;

  public class Human {

     private String name;
     private String sex;
    private int age;
   public String getName() {
         return name;
     }
    public void setName(String name) {
         this.name = name;
    }
    public String getSex() {
        return sex;
     }
     public void setSex(String sex) {
         this.sex = sex;
     }
     public int getAge() {
         return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
     public Human(String name, String sex, int age) {
      super();
         this.name = name;
         this.sex = sex;
         this.age = age;
     public void human()
     {
        System.out.println("姓名:"+this.name+" ,性别:"+this.sex+" ,年龄:"+this.age);
     }
 }

 package org.zuoye .;

 public class TestHuman {

      public static void main(String[] args) {

         Human zhangsan = new Human("张三","男",20);
         zhangsan.human();
         Human lisi = new Human("李四","女",21);
       lisi.human();    }
}
时间: 2024-10-13 16:18:56

zuoye2016.3.7的相关文章