Thinking in Java Fourth Edition Bruce Eckel Chapter 1 Exercise 10

Exercise 10: Write a program that prints three arguments taken from the command line. To do this, you’ll need to index into the command-line array of Strings.

Solution:

public class CommandArgTest
{
    public static void main(String[] args)
    {
        System.out.println("args[0] = " + args[0]);
        System.out.println("args[1] = " + args[1]);
        System.out.println("args[2] = " + args[2]);
    }
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *