0

why is it public

why should be public static void instead of private static void ?

18th Jul 2016, 9:06 AM
Sohn In Gi
Sohn In Gi - avatar
2 Respuestas
+ 1
main method is public because execution of program start with main and that is performed by JVM that is outside of your code so make the main method available to JVM we write main method public rather than private or protected I hope it will work for you
5th Aug 2016, 6:49 AM
sachin tomar
sachin tomar - avatar
0
private methods can't be accessed from another class, and Java is OOP (many classes...) Most of methods are public so we can use it when we work with objects of those classes. U will have privte methods later but they are mostly helper methods for some stuff inside class, for now just go with public...
18th Jul 2016, 9:18 AM
Petar Suvajac
Petar Suvajac - avatar