Why does Java not allow a top level class to be declared as private? Is there any other reason other than \"We can\'t access a private class\"?
This needs a simple understanding of why it is not required to declare classes as private in Java.
If your class is itself a standalone program/software (which is highly unlikely) then you would have already defined it in a project and a package specific for it. So adding the private keyword is redundant to it.
If that's not the case then default access is then it means your program/software depends on different classes to run. If we are declaring one class among them as private (in case if we could) then we are restricting its accessibility by other classes, etc. which isn't of any use. It simply means that the class declared as private by us isn't of any use for the code to run. Which again renders it useless.
If you mean package level access then for default access we don't need to declare any keyword before it.