我想知道记录这个潜在Point
课程的最佳方式是什么:
public class Point {
/* the X coordinate of this point */
private int x;
/* the Y coordinate of this point */
private int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}
x
我具体关心的是andy
属性及其各自的 getter 和 setter之间的重复,以及构造函数参数之间的重复。
并不是说我正在开发公共 API 或任何类似的东西,例如,我可以对某个变量进行一般性评论,然后让 getter 和 setter 具有相同的文本。我只是想避免在我自己的内部代码中重复注释。例如,有没有办法将构造函数getX()
的参数与属性联系起来?int x
x
谢谢