1 // Example 4.1 joi/examples/CommandLineArgsDemo.java 2 // 3 // 4 // Copyright 2003 Bill Campbell and Ethan Bolker 5 6 // A class illustrating the use of command line arguments. 7 // 8 // %> java CommandLineArgsDemo foo bar "b q" 9 // Echo command line arguments, 10 // surrounded by |...| 11 // |foo| 12 // |bar| 13 // |b q| 14 // 15 // Note the use of quotes to get embedded blanks. 16 17 public class CommandLineArgsDemo 18 { 19 public static void main( String[] args ) 20 { 21 System.out.println("Echo command line arguments, "); 22 System.out.println("surrounded by |...| "); 23 for (int i = 0; i < args.length; i++) { 24 System.out.println('|' + args[i] + '|'); 25 } 26 } 27 }