12.创建一个Point类,有成员变量x,y,方法getX(),setX(),还有一个构造方 法初始化x和y。创建类主类A来测试它。

package java1;

public class Point {
    
    int x;
    int y;
    
    Point(int x,int y)
    {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }
}
        Point a1=new Point(1,2);
        {
            a1.setX(10);
            System.out.println("X="+a1.getX()+"Y="+a1.y);
        }

 

posted @ 2016-09-19 23:46  张好好  阅读(950)  评论(0编辑  收藏  举报