楼主如果很吝啬,不愿意说出你的具体需求,那我只能写成这个样子了。public class Point { private final int x; private final int y; public Point() { this.x = 0; this.y = 0; } public Point(int x, int y) { this.x = x; this.y = y; } public int getX() { return this.x; } public int getY() { return this.y; } public String toString() { return "(" + this.x + "," + this.y + ")"; } }
private final int x;
private final int y;
public Point() {
this.x = 0;
this.y = 0;
}
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public String toString() {
return "(" + this.x + "," + this.y + ")";
}
}