Java Program to Print Command Line Arguments

Example:

class commandLineArguments {
    public static void main(String[] args) {
        for (String elements: args) {
            System.out.println(elements);
        }
    }
}

File Execution Commands:

Compile by > javac commandLineArguments.java  
Run by > java commandLineArguments one two three four

Output:

one 
two 
three 
four

Leave a comment