java basic question
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[])
The code will compile but not run.
The reason for the string[] is so that people can pass parameters through the command line.