Ajay Kamble wrote:My question was is one faster than the other? How JVM will deal with two imports?
One is not faster than the other.
Note that import statements are only directives for the compiler, to tell the compiler in which packages it can find classes that you use. It makes no difference in the bytecode that the compiler produces whether you import java.util.List or java.util.*.
You can check this yourself: write a small program with import java.util.List, compile it, and look at the bytecode (you can use the javap tool included with the JDK to disassemble the class file). Then change the import to java.util.*, compile and disassemble again. You'll see that the bytecode is exactly the same.
Whether one is "faster" than the other is not a reason to choose one over the other. There are, however, perfectly good other reasons to import java.util.List instead of java.util.*. The most important one is that importing java.util.* can make your program incompatible with a future
Java version:
Suppose that you have a class named "Something", you're using JDK 6 and you import java.util.*. Now, suppose that Java 7 comes out, and it has a new class in package java.util that by coincidence also happens to be called "Something". Your program now will not compile on Java 7, because the compiler doesn't know if with the name "Something" you mean your own class or the new class in java.util.
You won't have that problem when you import only those classes from java.util that you actually use.