Java for students logo
Need help with Java programming assignment? Get affordable Java homework help.

Print command-line arguments

Abstract

Java program, printing its command-line arguments.

Source code

PrintCommandLineArguments.java

public class PrintCommandLineArguments {

      public static void main(String[] args) {

            System.out.println("Command-line arguments:");

            for (String arg : args) {

                  System.out.println(arg);

            }

      }

}

Download PrintCommandLineArguments.java

Sample run

java PrintCommandLineArguments arg1 arg2 arg3 "complex arg 4"

Command-line arguments:

arg1

arg2

arg3

complex arg 4

 

Partners Ads