Why is using a wild card with a Java import statement bad?

后端 未结 17 1531
梦谈多话
梦谈多话 2020-11-21 13:07

It is much more convenient and cleaner to use a single statement like

import java.awt.*;

than to import a bunch of individual classes

17条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 13:56

    In DDD book

    In whatever development technology the implementation will be based on, look for ways of minimizing the work of refactoring MODULES . In Java, there is no escape from importing into individual classes, but you can at least import entire packages at a time, reflecting the intention that packages are highly cohesive units while simultaneously reducing the effort of changing package names.

    And if it clutters local namespace its not your fault - blame the size of the package.

提交回复
热议问题