It makes precisely zero difference at runtime. "import" is just a directive to tell the compiler how to interpret your code. By the time the .class files are produced, they contain no record at all of what you imported or how. Now, does what you import have any impact on the performance of a Java compiler? People have debated this before; generally the answer is that no, it has no noticeable affect. It's not at all like including too many headers in a C program. Finally, I should point out that style is a more important consideration than performance in this case. Importing single classes (at least, if you're only using a few classes from a package) makes it easier to the reader of your code to know where the various classes you're using came from. Anything that makes it easier to read your code is a Good Thing, single-class imports are generally to be preferred.
I like the method of showing the actual name of the class being imported because in the case of looking at old code, or someone elses code, it helps to know from what packages classes ar imported. For example, if I wasn't familiar with the SimpleDateFormat class, I could look at the import section of the code, see the import statement and then know where to look for documentation on that class. Just my opinion.
As Ernest pointed out, it doesn't make any difference. Personally I will import only the classes. But if I need to import more than 3 classes from the same package, I will do an import '*'
Post by:autobot
Alas, poor Yorick, he knew this tiny ad:
a bit of art, as a gift, that will fit in a stocking