GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Command Line Arguments in Java - GeeksforGeeks Command Line Arguments in JavaLast Updated : 28 Sep, 2026 Command-line arguments in Java are values passed to a program during execution through the command prompt. These arguments are stored as String values in the main() method parameter.
Command-line arguments are passed after the class name while running the Java program. Syntax:
![]() Example: In this example, we are going to print a simple argument in the command line.
Output: ![]() GeeksForGeeksExplanation:
Working of Command-Line Arguments
Example: Display Command-Line Arguments Passed to a Java ProgramTo compile and run a Java program in the command prompt, follow the steps written below.
Output: The command line arguments are:
Geeks
at
GeeksforGeeksExplanation: When the program is executed using java Hello Geeks at GeeksforGeeks, the JVM stores the three command-line arguments in the args array as args[0] = "Geeks", args[1] = "at", and args[2] = "GeeksforGeeks". Since args.length is greater than 0, the enhanced for loop iterates through the array and prints each argument on a separate line. Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |