黑马程序员技术交流社区

标题: 对象引用 [打印本页]

作者: zhao543    时间: 2017-3-23 17:14
标题: 对象引用
public class Test
{
    public static void main(String[] args)
    {
        Human aPerson = new Human(160);                 
    }
}

class Human
{   
    /**
     * constructor
     */
    public Human(int h)
    {
        this.height = h;
    }

    /**
     * accessor
     */
    public int getHeight()
    {
       return this.height;
    }

    /**
     * mutator
     */
    public void growHeight(int h)
    {
        this.height = this.height + h;
    }

    private int height;
}




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2