0

Static

why is it said that main method should always be static?

2nd Jan 2018, 1:03 PM
Shalini Jha
Shalini Jha - avatar
2 Antworten
+ 2
Because you want to get access to your main method without creating an instance of your class :)
2nd Jan 2018, 2:24 PM
Leander
Leander - avatar
+ 2
static access modifier binds the method (main) to the class, where it was declared, as such, there be no need for the virtual machine to have an object created based on that class before it can invoke the static method, and start the program. Hth, cmiiw
2nd Jan 2018, 2:29 PM
Ipang