Facts about Main Block In Java
Java When any java projects run, the first method called by JVM is main method. The entry point into application is the public static void main(String args[]) method:- Below are some facts about main method:- 1. Overload : We can overload main method with as many parameter as we want. But JVM call only the public static void main(String args[]) or public static void main(String[] args) method. 2. Override : We can't override main method because it is static. And secondly because overriding a method leads to method hiding. 3. Final : We can declare main method final, but it cannot be overridden. 4. Synchronized : We can definitely synchronized main method. 5. Non-static method call : We can call non-static method from main by creating an object as a local variable in main. Then, use the object to call non-static method as usual.