> Some people confuse what import does with what #include does. With
> C/C++, #includes actually add code to the source file, and therefore
> there is more to compile - can be slower if it is a lot of code. With
> Java, import is simply telling the compiler how to resolve class short
> name use to the fully qualified name. (<rant>I dislike the name
> import; I wish something like "ref" or "refersto" or "link" or "uses"
> or something that clearly states what import does was used
> instead</rant>).
That's not correct. java compilers compile everything that is imported.
I've run into this problem since I started hacking some code, then saved the
file, it wouldn't compile, then decided that I didn't really need it in
another file, commented out the references, except the imports, then tried
to compile it and got errors from the first file that it shouldn't have
touched. Plus global imports make debugging hard because it's hard to find
the correct package for a file if everything is a global import. On the
projects I work on people are publicly humiliated for using global imports,
it's considered as bad as checking in uncompilable code to the repository.
> As a style issue, listing each class is more of a maintenance
> nightmare than any benefit (class collisions are very rare; import
Rare? Maybe if you only use core java classes, but between many 3rd party
packages this is a definate problem.