Only with that you can pass arguments to the main program. If it would have been "String" you can just pass one argument, since it is a string array you can pass "n" number of arguments as strings to your program.
A single String would be possible as well; Visual Basic does it that way. However, that means that you have to do the parsing yourself. Trust me, it's not something you want to do. Splitting on spaces will not work because quoting (with ") allows spaces inside arguments. And by escaping it with \ you can even put " inside arguments, including arguments already surrounded by quotes. For example, "arg with \" and spaces" is one single argument.
Fortunately, by using a String, you don't need to worry about it. The shell (command prompt) does it all for you, passes that to the JVM, which in turn passes it to your application.
That is fine Chris. I went through the page. My question is that why is it that we cannot do without passing a String array to the main thread? Why is it that the JVM fails to recognize the main() method & throws an exception saying:
Exception in thread "main"
if I try to run a Java Application witout passing that String  args? Please elaborate.
Joined: Jul 16, 2010
Consider you have a method some thing like this
You can invoke this method only by passing an int like
myMethod(a) // "a" holding some int value
You can never invoke this method like this
Similary JVM always invokes the main method which takes String array as an argument. If it cant find one then a exception would be thrown.
That's the way Java is designed. It could also have used a no-argument main method if it cannot find the one we all know and love, but that would require an extra check. In pseudo code:
In practice it will be a bit harder. The looking up of the method already throws the error. So the actual pseudo code would be more like this:
That said, this try-catch is Java code. The JVM doesn't use Java to call the main method, it uses JNI. The code in the try-block is pretty straightforward in JNI, it's the catching that is the problem.