I have a model where I have something like this
public class Foo {
private int foo;
private int bar;
public setFoo(int foo) {
bar = someFunction(foo);
}
}
So I'd like user to be able to see bar, but not directly affecting it. Is that achievable?
I think what you need is a getter for bar
.
public int getBar() {
return bar;
}
So it is visible but not changeable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.