go to previous page   go to home page   go to next page

Answer:

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 );
  }
}

Arguments with Spaces

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.


QUESTION 13:

(Thought Question: ) Are the data on a list always processed in order?