Command-line arguments: Difference between revisions

Content added Content deleted
m (→‎{{header|C++}}: Minor formatting changes)
Line 1,306: Line 1,306:


=={{header|Java}}==
=={{header|Java}}==
The arguments will be passed to <code>main</code> as the only parameter.<br />
The array is non-null.
<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
public static void main(String[] args)
/* arguments are passed to the program via 'main' */
public static void main(String[] args) {
/* 'args' is non-null */
for (String arg : args)
System.out.println(arg);
}
</syntaxhighlight>
</syntaxhighlight>
Running this command
Running this command