public class A{
}
private class B{
// no error
}
This shouldn't even work (see Java Language Specification):
It is a compile-time error if a top level type declaration contains
any one of the following access modifiers: protected, private, or
static
Are you sure you haven't declared class B
as an inner class?
It doesn't make sens to declare a top-level class as private
, since private restricts the visibility of members to the enclosing top-level class/interface. If your class is a top-level class (whether or not in its own file), you'd at least want package-level visibility (no modifier at all).