请为Point.java添加外部程序访问或修改该类对象的数据使用的接口(public修饰的getter方法和setter方法)。

anshe80 2011-11-27 12:27:18
public class Point {
private int x = 0;
private int y = 0;
// a constructor!
public Point(int a, int b) {
x = a;
y = b;
}
}
...全文
107 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang7535067 2011-11-27
  • 打赏
  • 举报
回复
public void setX(int x)
{
this.x = x;
}
public int getX()
{
return this.x;
}

public void setY(int y)
{
this.y = y;
}
public int getY()
{
return this.y;
}
huntor 2011-11-27
  • 打赏
  • 举报
回复
import java.io.Serializable;

public class BasicBean implements Serializable {
boolean property;
public BasicBean() {
}
public boolean getProperty() {
return property;
}
public boolean isProperty() {
return property;
}
public void setProperty(boolean newValue) {
property = newValue;
}
}
huntor 2011-11-27
  • 打赏
  • 举报
回复
public void setX(int x) {this.x = x;}
public int getX() {return this.x;}

51,408

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧