About import command
Hi all,
We are using import command as
import java.io.*, import java.util.* etc in the program.
Consider i am having a class A.
Is there any difference related to Memory consumptions forclass A while writing import command as
import java.util.HashMap ;
rather than
import java.util.*;
in the case import java.util.HashMap i am importing only the class HashMap where as in the case import java.util.* , i am importing all the classes present in util package.
What is the diference between the two things related to Memory allocated Forclass A.
Importing does not load any classes.
It has precisely ZERO effect at runtime.
All that importing does is tell the compiler, "When I say List, I mean java.util.List," so that a) you get to type less and b) your code is less cluttered.
Having said that, it's generally considered better practice to import specific classes, because that makes it clearer where everything came from.
Having said that, however, when I'm working in a shop which doesn't have strict rules about import conventions, I sometimes import * from a few very common packages--java.io, java.sql, java.util.
jverda at 2007-7-12 23:06:19 >
