+ 1

Why java main method is public?

16th Jul 2016, 1:00 PM
WPimpong
WPimpong - avatar
4 Respuestas
+ 2
Main method is public so that JVM can access the main method and execute it.
16th Jul 2016, 7:50 PM
deepanshu7211
+ 1
it's a rule :)
17th Jul 2016, 8:16 AM
William Jing
William Jing - avatar
+ 1
public modifier is used in main function because when we declare a function with public modifier it is visible to all classes and it can be accessed by anything.
17th Jul 2016, 11:32 AM
Umamaheswararao Tumma
Umamaheswararao Tumma - avatar
+ 1
so that the JVM can call it. it is the main point of entry out execution for your program.
22nd Jul 2016, 4:26 AM
Eric Gitangu
Eric Gitangu - avatar