-
Notifications
You must be signed in to change notification settings - Fork 0
/
main method.txt
20 lines (15 loc) · 957 Bytes
/
main method.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
In Java, String[] args is a parameter in the main() method of a Java program. It stands for "command-line arguments" and is used to pass arguments to the Java program when it is executed from the command line
Here's a breakdown of what each part means:
String[]: This declares an array of strings. In Java, an array is a data structure that holds a fixed-size sequential collection of elements of the same type.
args: This is the name of the array parameter. You can name it whatever you want, but args is a common convention and stands for "arguments".
When you run a Java program from the command line like this:
java YourProgramName arg1 arg2 arg3 ...
here is the program is given
public class Main {
public static void main(String[] args) {
// Print out each command-line argument
for (int i = 0; i < args.length; i++) {
System.out.println("Argument " + i + ": " + args[i]);
}
}
}