The String array parameter of the main method

  1. The main() method in a Java program is an array of String which is initialized by the user command interface (e.g., UNIX shell)

        public class PrintArgs
           public static void main(String[] args)
    	  // args is an array of String...
    	  // args[i] points to i-th `argument' of the command line    
    For example:
        UNIX>> java PrintArgs a b c
        args[0] = "a"
        args[1] = "b"
        args[2] = "c"

  2. DEMO program: