我有一个模型,我有这样的东西
public class Foo {
private int foo;
private int bar;
public setFoo(int foo) {
bar = someFunction(foo);
}
}
所以我希望用户能够看到酒吧,但不会直接影响它。这是可以实现的吗?
答案 0 :(得分:0)
我认为你需要的是bar
的吸气剂。
public int getBar() {
return bar;
}
所以它是可见的,但不可更改。