From JavaProgramming.
Visibility of class members is almost the same as in C++, with a couple of important exceptions:
Default (no visibility specified)
/* TestVisibility.java */ class Classname { int defaultVar; public int publicVar; protected int protectedVar; private int privateVar; } public class TestVisibility { public static void main(String[] args) { Classname foo = new Classname(); foo.defaultVar++; // Visible within the package foo.publicVar++; // Evidently public visibility foo.protectedVar++; // Visible within the package!!! foo.privateVar++; // Compiler error: privateVar has private access } }