Passing Arguments via Command-Line Execution - Java Object Oriented Design

Java examples for Object Oriented Design:main method

Description

Passing Arguments via Command-Line Execution

Demo Code

public class Main {
    public static void main(String[] args){
        if(args.length > 0){
            System.out.println("Arguments that were passed to the program: ");
            for (String arg:args){
                System.out.println(arg);
            }//from   ww w .  j  av a 2s . c  o  m
        } else {
            System.out.println("No arguments passed to the program.");
        }
    }
}

Result


Related Tutorials