What happens If not provide String array as argument to main method

What happens If not provide String array as argument to main method

Answer: String[] args as parameter in main method used to passing in command line arguments. To run java program it should have public static void main(String[] args) . You could compile it successfully but run time it will throw exception as shown above.

The args array contains all command line parameters passed in to your Java application. For example, if you call your application like this:

java MainMethodTest arg1 arg2 arg2

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *