Monday, 1 August 2011

How to use Command-Line Arguments


Using Command-Line Arguments
Helps us to pass information into a program when it is run
class CommandLine
 {
public static void main (String args [ ] )
{
for (int i= 0; I < args.length ; i ++ )
System.out.println(“ args [ “ + i + “ ] ; “ + args [ i ]) ;
}
}

To execute a program, we write from the command prompt:

java CommandLine this is a test 100-1

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More