PhysicsPrincess
PhysicsPrincess

Reputation: 372

Importing the super package in a subpackage java

Sorry, this is a Java newbie question.. Does it make sense to create a subpackage that needs to import the "super" package? This is possible but is it something that is usually done / logical to do?

Thanks.

EDIT: what about the other way around? Packages that import their subpackages?

Upvotes: 4

Views: 648

Answers (1)

Andy Turner
Andy Turner

Reputation: 140494

There is no such thing as a "subpackage" in Java.

Despite the appearance that com.example.some and com.example.some.thing are related (and the practical fact that thing is likely a subdirectory inside com/example/some), there is no super/sub relationship between them.

They are just two separate packages. If you want to use things from one package in the other package, you have to either import or fully qualify the name.

Upvotes: 3

Related Questions