Point类
//1. 创建Point类,包含私有x和y属性,设计对应的getter/setter。
class Point{
//x,y
private int x;
private int y ;
public Point(Integer x ,Integer y) {
this.x= x;
this.y = y;
}
public Integer getX() {
return x;
}
public void setX(Integer x) {
this.x = x;
}
public Integer getY() {
return y;
}
public void setY(Integer Y) {
this.y = y;
}
}
创建Test类,在main中:创建两个Point对象,测试getter/setter。
// 创建Test类,在main中:创建两个Point对象,测试getter/setter。
public class Test {
public static void main(String[] args) {
Point po1=new Point(20,21);
Point po2=new Point(22,22);
System.out.println(po1);
System.out.println(po2);
}
}



