public static void main( String arg[] )
In the above statement, can I use an int
array in place of the String
array? What happens if I don't put anything in the parenthesis, i.e if I use an empty parenthesis?
When you compile the code with the changes that you mentioned, it will compile successfully. When you try to run, JVM checks for the main method with String array as arguments. Since there is no main method with String array as argument, your code will not execute successfully and it throws NoSuchMethodError.
No, I think you can't use int array instead of String array.because the argument int
is used by the operating system to pass an integer value specifying the number of command-line arguments entered by the user. so you must follow the following pattern.
public static void main(String[] args)
public static void main(String args[])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With