I was just wondering the difference between String[] and String in main method
public static void main(String[] args) {
VS
public static void main(String args) {
The main method in Java takes only an Array of Strings:
The main method accepts a single argument: an array of elements of type String.
public static void main(String[] args)
Taken from here.
I think that you are looking at an overloaded method of the main method, something which was created by someone else and is not the actual entry point of the application.
When you execute your program the main method is called and the command-line arguments are passed as individual strings inside the String array which is the argument of main (first case).
It's easier to manage than just passing the entire argument list as a single string (second case) and then having to parse it somehow (you can't build your program like this anyway).
No such method if you are thinking to execute class using main
public static void main(String args) {
String[] is used to signify that the user may opt to enter parameters to the java program at command line. We can use both String[] args or String args[]. The Java compiler would accept both forms.
java.lang.NoSuchMethodError: main Exception in thread "main"