创建一个Point类,有成员变量x,y,方法getX(),setX(),还有一个构造方 法初始化x和y。创建类主类A来测试它
package com.hanqi.test; public class Point { private int x; private int y; Point(int xx,int yy) { x=xx; y=yy; } public int getX() { return x; } public int getY() { return y; } }
Point pt=new Point(1,2); System.out.println("x值是"+pt.getX()+"y的值是"+pt.getY());