Shouldn't “import foo.*” also include subpackage “foo.bar.*”?

后端 未结 3 2022
隐瞒了意图╮
隐瞒了意图╮ 2021-01-12 08:22

Studying Java, I\'ve thought about a, to me, rather confusing property of many tutorials. Consider the following two imports from a sample tutorial:

import j         


        
3条回答
  •  梦毁少年i
    2021-01-12 08:52

    Each package name ("a.b.c") is a discrete package. Two packages with similar naming prefix ("a.b.c" and "a.b.d", for example) are separate packages for the language, both for namespaces and for access control.

    For humans, of course, this represents a possible relation between the packages.

提交回复
热议问题