Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing the super package in a subpackage java

Tags:

java

package

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?

like image 474
PhysicsPrincess Avatar asked Oct 20 '25 13:10

PhysicsPrincess


1 Answers

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.

like image 93
Andy Turner Avatar answered Oct 23 '25 08:10

Andy Turner