0
Ahat is command line argument and when do we need that?
command line argument
4 Respuestas
+ 2
A command line arguement just means that you're taking input from the command line (command prompt) rather than a GUI or from your own code. It's achieved with a scanner that asks for in.nextInt() or any other variable type.
+ 1
Command line argument is an argument that is sent via the command line.
Ex.
class CommandLineArgument{
public static void main(String [] args){
System.out.println(args[0]);
}
}
(After)
>javac CommandLineArgument.java
(in the command line you write:)
>java CommandLineArgument Something
Output:
Something
(The text you write after)
>java CommandLineArgument <here>
(is put into args[0].)
You can take as many args[] you like. The array will adjust/grow.
0
now I am clear with your answer but is it necessary to create a scanner i think in many case we use in.nextInt() but that is for giving the code from keyboard if not please raise my doubt
0
You do not need to create a Scanner-object to use the args[]-array.