Given:
What is the result?
The Java launcher looks specifically for a method with the exact signature public static void main(String[] args) to use as an application's entry point; overloaded main methods declared with an int[] or an Object[] parameter are valid, distinct overloads that compile without error, but they are never chosen by the JVM as the entry point regardless of how the program is invoked. Running java MainTest 1 2 3 therefore invokes only the String[] overload, and since the command-line arguments are passed as strings, args[0] is the string "1", so the program prints "String main 1".
Community Discussion