Scanner | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Scanner

import java.util.*; //you can use that star * instead of Scanner and it does the same job class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); System.out.println(myVar.nextLine()); } }

20th Mar 2018, 12:34 PM
Ahmed Amr
Ahmed Amr - avatar
1 Answer
+ 3
Yes, you are correct. This symbol * indicates to import all the available classes, objects, methods and properties in that package. It is necessary only when you need many of them from a single one package. It prevents large lengths of code and also saves time and labour. However, this may cause the program to run slow. In that case, you need to import all of them one by one!
20th Mar 2018, 1:11 PM
Naveen Maurya
Naveen Maurya - avatar