class InputDemo { public static void main ( String[] args ) { int sum = 0; for (int j=0; j < args.length; j++ ) sum += Integer.parseInt( args[j] ); System.out.println( "Sum: " + sum ); } }
A command line argument that contains spaces is surrounded by quotes:
C:\>java SomeProgram "one argument" "another argument"
The Java system creates an array of String
references if there are any on the command line.
But the program is free to ignore them.
(Thought Question: ) Are the data on a list always processed in order?