Posts

Showing posts with the label Overriding main method

public static void main(String [] args) - Full Explanation

Why JVM Call main() method? JVM is a program in which the main() method is configured that is the reason JVM called the main method. we can change the name of the main() method but we need to change the method calling in JVM. Explanation of the main method : public static void main(String [] args) is a method that is called by JVM.  Public : Public is an access modifier of the main method. the main method is public because the JVM can call this method from anywhere. static : without creating an object JVM can call this method that's why the main method is static. without an existing object also JVM has to call this method and the main method is not related to any Object. void:  void is a return type of the main method, the main method not returning any value to JVM. main : this is the method name that is configured in JVM.  String[] args : these are command-line arguments. The above syntax is very strict if we performed any change we will get a Runtime exception i.e No su...