0

Ahat is command line argument and when do we need that?

command line argument

29th Jul 2016, 4:01 AM
eugene dakarapu
eugene dakarapu - avatar
4 Answers
+ 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.
29th Jul 2016, 6:43 AM
nk361
nk361 - avatar
+ 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.
29th Jul 2016, 8:12 AM
Tommy Taraldsvik
Tommy Taraldsvik - avatar
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
29th Jul 2016, 7:20 AM
eugene dakarapu
eugene dakarapu - avatar
0
You do not need to create a Scanner-object to use the args[]-array.
29th Jul 2016, 6:10 PM
Tommy Taraldsvik
Tommy Taraldsvik - avatar