Let me summarize the main method in JAVA (which is confusing at the beginning).
1. can we have more than one main () method in a class? Ans: Yes. You can have several methods named main, but with a different signature. These methods will be overloaded. BUT the main method with the next cigar will be considered as the entry point of the application.
public static void main(String args[] ), which is similar to public static void main(String... args) or public static void main(String[] args)
2. can we have more than one main method in a java program? An: Yes . We can have different classes having basic methods.
Then which one will be considered as the entry point to the application?
When starting a program with such classes, the user will be asked to choose among the classes so that they act as an entry point.
source share