You can use at most one public class per one java file (COMPILATION UNIT) and unlimited number of separate package-private classes. Compilation unit must named as public class is. You also can have in your public class the unlimited number of inner classes and static nested classes .
Read moreHow many classes can a .java file have?
As we know that a single Java programming language source file (or we can say . java file) may contain one class or more than one class . So if a . java file has more than one class then each class will compile into a separate class files.
Read more