From my experience, it is ideal to set variables as private and to provide accessors and modifiers to each variable.
This way, you can create read only variables, or write only variables depending on your requirements.
Below implementation shows a write only variable.
private String foo;public void setFoo(String foo) { this.foo = foo; }private String getFoo() { return foo; }
Below shows a read only variable.
private String foo;private void setFoo(String foo) { this.foo = foo; }public String getFoo() { return foo; }