0

Possible Duplicate:
Performance difference between a wild card import and the required class import
Implications importing java packages with wildcard

My QA leader set up a checkstyle rule that java.util.* can not appear in the source code, use java.util.XXX instead. For example , you can only write:

import java.util.Date;
import java.util.List;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
// ... may be thousands import statement here 

but not allowed:

import java.util.*;

If anyone do not follow the rule, QA team will not do the integration test. He told me that the style of import java.util.XXX is more clear than import java.util.*, and makes JVM run faster. Is it true ?

Community
  • 1
  • 1
爱国者
  • 3,988
  • 7
  • 45
  • 66

1 Answers1

3

If you include java.util.*, you're including all of the classes in the java.util package.

When including java.util.classname, you're only including the specified class in the java.util package.

Using java.util.* will not slow down the JVM because imports are handled at compile time, not runtime.

Zach Latta
  • 3,151
  • 5
  • 23
  • 38