package com.chuoji; public class Point { private double x; private double y; private double a; Point(double x,double y) { this.x=x; this.y=y; this.a=x+y; } public double getX() { return x; } public void setX(double x) { this.x = x; } public double getY() { return y; } public void setY(double y) { this.y = y; } }
package com.chuoji; public class Text00 { public static void main(String[] args) { Point b=new Point(2,3); System.out.println("原始状态x="+b.getX()+"y="+b.getY()); b.setY(4); b.setX(6); System.out.println("改变状态x="+b.getX()+"y="+b.getY()); } }