Example

public class TestClass {
public int num = 1;
}


Solution
A suggestion to make the field protected and create public methods to access the field.


public class TestClass {
private int num = 1;
public int getNum() {
return num;
}
}