+ 2
What is the difference between private static void Main() and public static void Main() in c# and JAVA?
what is the difference about using private or public in Main method in c# and JAVA?
2 Réponses
+ 4
First it's important to know that the "main" method is used as an entry point for the application, this is why it must be accessible with the access modifier "public" in it's signature. In Java the "main" method used as entry point must be "public static void main(String []) args{}", but if you create a perfectly fine "private static void main(){}" method, the compiler should not complain at all (at least in Java), but just know that the compiler will think of that private main method as an overwritten version of "main", and it will not be used as the entry point of your application. Hope this helped you understand better Norman.
+ 3
thank you