-1

Is there a downside to doing this:

import java.util.*;

rather than importing a specific part:

import java.util.Stack;

Does it take more time to build for example?

DannyD
  • 2,732
  • 16
  • 51
  • 73

2 Answers2

2

You wouldn't feel the difference, but for the sake of clear and readable code you should import only the classes you actially need.

Konstantin Yovkov
  • 62,134
  • 8
  • 100
  • 147
  • 1
    *You wouldn't feel the difference* because the compile will replace `import foo.bar.*` by `import foo.bar.NeededClass1; import foo.bar.NeededClass2; import foo.bar.NeededInterfaceX;` and on for you, but I consider it is a bad practice, even more when IDEs already have a function to complete this for you. – Luiggi Mendoza Dec 16 '13 at 15:30
0

No. Some people consider .* as a bad practice since it is less readable and does not allow you to understand the class' relationships with other types just by looking at imports.

SiN
  • 3,704
  • 2
  • 31
  • 36