Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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}  


This post first appeared on Java Programs, please read the originial post: here

Share the post

Command-line Arguments

×

Subscribe to Java Programs

Get updates delivered right to your inbox!

Thank you for your subscription

×