is there any benefit of writing public classes for the main method?
问题 We can write a java program with one non-public class containing a main method -- it'll compile and run just fine. Why do people make the main class public? Is there any benefit? 回答1: There is no benefit of making the class public for the sake of it having a main method. That being said, there isn't really much of a reason not to either. Chances are the main class is either going to be very short with few, if any, substantial methods in it, or it's going to be baked into one of the core