can anybody explain me this syntax scanner MyVar = New scanner (system.in); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can anybody explain me this syntax scanner MyVar = New scanner (system.in);

16th Sep 2016, 11:33 AM
abhishek
abhishek - avatar
5 Answers
+ 2
Scanner: the class of the object MyVar: the name of the object =: assignment operator New Scanner(system.in): create a new object of type Scanner that will read from system.in (the input stream).
16th Sep 2016, 11:39 AM
Zen
Zen - avatar
+ 2
the above statement is basically used to create a scanner object in order to cut short the tiresome process of printing new Scanner statement when the program requires multiple inputs For example, 1. using scanner object : Scanner myVar = new Scanner( System.in ); int a = myVar.nextInt(); int b = myVar.nextInt(); double c = myVar.nextDouble(); 2. without scanner object : int a = new Scanner(System.in).nextInt(); int b = new Scanner(System.in).nextInt(); double c = new Scanner(System.in).nextDouble(); As u can see it saves a great deal of time and energy. All this information may not be what u asked for but i ve tried to explain the basic use of this statement. As for the meaning of the statement. It is exactly what Zen has given. Hope u find this helpful !!! Happy coding !!
18th Sep 2016, 7:24 AM
Andy
Andy - avatar
+ 1
used to get input from user that's it!!
16th Sep 2016, 12:23 PM
Jaydip Gadhesariya
0
thank you zen
16th Sep 2016, 12:22 PM
abhishek
abhishek - avatar
0
thanks a lot
16th Sep 2016, 12:25 PM
abhishek
abhishek - avatar