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

前端 未结 7 579
一生所求
一生所求 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:37

    As you can read in this link on Oracle docs, under the heading Apparent Hierarchies of Packages:

    At first, packages appear to be hierarchical, but they are not. For example, the Java API includes a java.awt package, a java.awt.color package, a java.awt.font package, and many others that begin with java.awt. However, the java.awt.color package, the java.awt.font package, and other java.awt.xxxx packages are not included in the java.awt package. The prefix java.awt (the Java Abstract Window Toolkit) is used for a number of related packages to make the relationship evident, but not to show inclusion.

提交回复
热议问题