Processing Command-line Arguments Inside the main() Method - Java Object Oriented Design

Java examples for Object Oriented Design:main method

Description

Processing Command-line Arguments Inside the main() Method

Demo Code

public class Main {
   public static void main(String[] args) {
    // args contains all command-line arguments
    System.out.println("Total Arguments:" + args.length);
    /*from  www. java2 s  .  co m*/
    // Display all arguments
    for(int i = 0 ; i < args.length; i++) {
      System.out.println("Argument #" + (i+1) + ":" + args[i]);
    }
  }
}

Result


Related Tutorials