I just wrote a little test program:
public class ClassField {
    int a = 10;
    public int getValue() {
        return a;
    }
    public void setValue(int a) {
        this.a = a;
    }
}
public class Main {
    public static void main(String[] args) {
        ClassField test1 = new ClassField();
        ClassField test2 = new ClassField();
        System.out.println(test1.getValue());
        test1.setValue(20);
        System.out.println(test1.getValue());
        System.out.println(test2.a);
        test2.a = 20;
        System.out.println(test2.a);
    }
}
The program gave out the output as expected:
10
20
10
20
As I realised, there were 2 ways of accessing the fields: by accessing it directly, and by accessing it indirectly through a method. Which way is generally considered as better?
 
     
    