Example

public class TestClass {
protected int num = 1;
}


Solution
A suggestion to make the field private and create a public method to access the field.


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