0
how to get input by command line argument??or without scanner class
2 Answers
+ 1
Do you mean that?
Scanner sc=new Scanner(System.in);
System.out.print("Enter Your Name: ");
String input=sc.nextLine();
0
if u want give your input through command line arguments we have to give input during execution
ex: usually in cmd we use javac filename.java to compile and java filename to execute
if u want to give input then we have give like this
// if u want to give two no.s as input then
java filename 1 2 // for integers
java filename ram shyam // for two strings.
to print these variables we have to use args string which is declared in main method
System.out.println(args[0]); // prints 1
System.out.println(args[1]);// prints 2