It makes no difference at runtime. At compile-time a wildcard import can result in longer compile times, but it's one of those things where you would probably only notice in the aggregate. The difference, most of the time I'd say, won't be enough to be of any real concern.

There is of course the debate about which leads to more readable code. This is generally a matter of taste. I personally prefer always importing specific classes because I like being able to look in one place to see exactly what a class depends on. Some people feel that using wildcards reduces the "noise" of a lot of import statements, which does make some sense.

One thing to consider in favor of specific imports is that with wildcard imports you can run into ambiguities. If you have:

import foo.*;
import bar.*;

... and there happens to be a class Node in both packages, that you want to use, you have a problem. Also, even if Node only exists in package foo initially, and then later someone adds a Node class to package bar, all of a sudden you'll find that your class doesn't compile and you'll have to track it down. Kind of annoying if it's in production code that has been compiling properly for a year and all of a sudden it doesn't and the guy that originally wrote it is gone, now someone potentially less familiar with the code has to figure it out.

Frank

N G wrote:
Does anyone know if it makes any kind of difference if you use "*" in your
import statements like:
import java.util.*;
 vs.
 import java.util.Collection;
 Is one better than the other? Does one take longer than the other when
compiling/executing?
 Thanks,
NG.


--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to