No arguments command line String array Main method will null or empty

No arguments command line String array Main method will null or empty

Answer: An array of String is always passed, even if no command line parameters are present. In that situation the length of the array is 0, see example below and test by yourself :

package com.javahonk;

public class MainMethodTest {

    public static void main(String[] args) {
	if (args.length == 0) {
	    System.out.println("No parameters were passed!!!");
	}
    }

}

 

Leave a Reply

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

I am not Robot *