Possible Duplicate:
Can we overload the main method in Java?
When I tryed to compile and run following code, it’s working and I see “A” on the console.
Why?
In my mind (String… args) it is the same (String arg, String[] args).
public class AFewMainExample {
public static void main(String... args) {
System.out.print("A");
}
public static void main(String args) {
System.out.print("B");
}
public static void main(String[] args, String arg) {
System.out.print("C");
}
public static void main(String arg, String[] args) {
System.out.print("D");
}
}
Parameters (order (or) type (or) both) are different for each of the main method, which leaves only one main method with real main syntax, so no issues.
If you add following main method you will see compile time error, because now there are two methods with exact syntax.
Read this tutorial for more info on overloading.