go to previous page   go to home page   go to next page
System.out.println( args[0] );

Answer:

stringA

Command Line Arguments



command line array

The words on the command line after the name of the program are the command line arguments. These are familiar to Unix programmers, but less familiar to Windows programmers. They are a convenient way to pass values into a program without a user dialog. There may be any number of command line arguments. The arguments are strings of characters, although some characters like < and > are not allowed. Each argument is separated from its neighbors by spaces.

Not all computer systems support command line arguments. Older Apple computers do not have a command line.

Here is a sample program:



public class StringDemo
{
  public static void main ( String[] args )
  {
    for (int j=0; j  < args.length; j++ )
      System.out.println( "Parameter " + j + ": " + args[j] );
  }
}

QUESTION 10:

Say that the user started this program with the command line:

C:\>java StringDemo stringA stringB stringC

What does the program print?


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