java why is main method static code example
Example 1: why main method static
Because the object is not required to call the static method.
If we make the main method non-static,
JVM will have to create its object first and then call main() method which
will lead to the extra memory allocation.
Example 2: do i have to use static methods in java main
Use a static method
when you want to be able to access the method
without an instance of the class