how to get input by command line argument??or without scanner class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to get input by command line argument??or without scanner class

17th Sep 2016, 5:58 PM
Shubham Sarode
Shubham Sarode - avatar
2 Answers
+ 1
Do you mean that? Scanner sc=new Scanner(System.in); System.out.print("Enter Your Name: "); String input=sc.nextLine();
17th Sep 2016, 6:07 PM
Ahmad Samy
Ahmad Samy - avatar
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
18th Sep 2016, 3:04 AM
Teja Naraharisetti
Teja Naraharisetti - avatar