Why main ( ) method in Java is declared as static?
The static modifier means that it does not have to be instantiated to use it. Before a
program runs there are technically no objects created yet, so the main method, which is
the entry point for the application must be labeled static to tell the JVM that the method
can be used without having first to create an instance of that class. So main method should be declared as follows:
public static void main (String[] args) { lots of your java code...}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment