I am reading some Java text and the text says that we can only apply public
or default
access modifier for class and interface. Therefore, it is a
top level classes can only have public
or default
access, but internal classes can have private access
:
public class TestClassAccess
{
public static void main(String[] args)
{
new TestClassAccess().new TestClassPrivateAccess();
}
private class TestClassPrivateAccess
{
TestClassPrivateAccess()
{
System.out.println("I'm a private class");
}
}
}