Input parameter of Main method
Main method takes a string array as the input argument. Lets do some experiments with it.
Code:
public class MainClass {
public static void main(String[] args) {
System.out.println("No. of argumetns are: " + args.length);
for(int i= 0;i < args.length;i++)
System.out.println("Argument " + i + " is : " + args[i]);
}
}
String delimiter is a space character.
is args[] always non-null
Looking at the code, which I will probably put in several places in my code, I get two questions:
1. Is args[] always non-null/
2. One would expect this code does not drop into the for loop if there are no command line parameters. If so, this would be a handy tool for checking if anything provided on command line.