我正在尝试使用Point(double x, double y), getX(), getY()
创建一个点并使用toString()
. 我在任何地方都找不到如何执行此操作的示例。
public class Point {
private final double x;
private final double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
@Override
public String toString() {
return ("(" + x + "," + y + ")");
}
}