user12394078
user12394078

Reputation: 63

Is relationship of a subpackage in one package any different then relationship of two different packages in Java

Regarding following Question: Does the star import include subpackages in Java?

so there is nothing special about subpackeges in Java they are considered as totally different packages?

Example: relationship of package A containing subpackage B is the same as relationship of package A to some other Package C.

Upvotes: 0

Views: 38

Answers (1)

Big Pumpkin
Big Pumpkin

Reputation: 4467

That is correct.

According the JLS

The hierarchical naming structure for packages is intended to be convenient for organizing related packages in a conventional manner, but has no significance in itself other than the prohibition against a package having a subpackage with the same simple name as a top level type (§7.6) declared in that package.

For example, there is no special access relationship between a package named oliver and another package named oliver.twist, or between packages named evelyn.wood and evelyn.waugh. That is, the code in a package named oliver.twist has no better access to the types declared within package oliver than code in any other package.

Upvotes: 3

Related Questions