why main is used for naming main method? can we use any other identifier for naming main method?
Answers
Answer:
Valid variants of main() in Java
We know that a Java code begins to execute from the main method. During runtime, if JVM can’t find any main method then we will get a runtime exception:
No such Method Error:
Main method not found in class, please define the main method as:
public static void main(String[] args)
to avoid this problem there should be the main method. We also know that the java main method has a particular prototype, which looks like:
public static void main(String[] args)
Even though the above syntax(prototype) is very strict but some little changes are acceptable. This makes it not so strict that if we perform any change then we will get a runtime exception. We can do several allowed modification to our main method.
The following Changes are acceptable.
Let’s understand the different variants of main() that are valid.