“java source file must have at least one public class” Uh no, it doesn’t need to have anything at all .
Read moreHow do you call a public class in Java?
To call a method in Java, write the method name followed by a set of parentheses (), followed by a semicolon ( ; ) . A class must have a matching filename ( Main and Main.
Read moreCan a Java file have no public class?
The actual requirement is slightly different: every Java public class must be in a compilation unit with the name PublicClassName. java . But it’s perfectly fine to have a compilation unit that does not contain a public class .
Read moreHow many public class can we have in Java?
A Java file contains only one public class with a particular name . If you create another class with same name it will be a duplicate class. Still if you try to create such class then the compiler will generate a compile time error.
Read more