10x Blogs Directory

Thursday, March 5, 2009

Command-line Arguments

l
  • A Java application can accept any number of arguments from the command-line. 
  • Command-line arguments allow the user to affect the operation of an application. 
  • The user enters command-line arguments when invoking the application and specifies them after the name of the class to run.  
  • In Java, when you invoke an application, the runtime system passes the command-line arguments to the application's main method via an array of Strings.

    public static void main( String[] args )


    Each String in the array contains one of the command-line arguments

    Example:

    1public class CommandLineSample
    2{
    3 public static void main( String[] args ){
    4
    5 for(int i=0; i
    6 System.out.println( args[i] );
    7 }
    8
    9 }
    10}  

1 comment:

  1. good work u did it man .Its really fine for beginners

    ReplyDelete