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.
Used to provide input without hardcoding values in the program.
Helps make programs flexible and reusable for different inputs.
Commonly used for file names, configuration values, and user data at runtime.
Command-line arguments are passed after the class name while running the Java program.
Syntax:
java Geeks Hello World
The JVM collects these values and passes them to the main(String[] args) method.
Hello -> stored in args[0]
World -> stored in args[1]
Example: In this example, we are going to print a simple argument in the command line.