Static import for java.util | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Static import for java.util

Why the following code is not working in which I want to static import java.util? https://code.sololearn.com/crjfuDdwGU4P/?ref=app

24th Jun 2018, 2:11 AM
harshit
harshit - avatar
2 Answers
+ 1
We can "import static" It is a concept in java.
24th Jun 2018, 3:04 AM
harshit
harshit - avatar
+ 1
static import is used so that we can use static member of a class without class name. There is no static member named next in Scanner class. nextInt() is an instance method. So you have to create object before using it. You can't use static import in this context.
24th Jun 2018, 3:10 AM
Nikhil Sharma
Nikhil Sharma - avatar