What About using import java.* for using all sub-packages under the package 'java'?

前端 未结 7 658
一生所求
一生所求 2021-01-13 19:06
import java.*;

Why cannot I do this importing ?? Instead of importing the all class in a particular sub-package of the package \'java\' , I tried t

7条回答
  •  青春惊慌失措
    2021-01-13 19:58

    Using a wildcard when importing classes may clutter your classes namespace so if you'll have a class named ClassA in more then one import (e.g. import com.example1.* and import com.example2.* where ClassA is defined in both and you need only the implementation in com.example1) you will have a conflict so only import what you really need to use.

    Most IDEs allows you to easily organize your imports so only the classes that you really need to use will be imported

提交回复
热议问题