Specifications
Sun Services
Java™ Programming Language
Module 9, slide 5 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Command-Line Arguments
1 public class TestArgs {
2 public static void main(String[] args) {
3 for ( int i = 0; i < args.length; i++ ) {
4 System.out.println("args[" + i + "] is ’" + args[i] + "’");
5 }
6 }
7}
Example execution:
java TestArgs arg1 arg2 "another arg"
args[0] is ’arg1’
args[1] is ’arg2’
args[2] is ’another arg’










