Java – Import the super package in the child package java

Import the super package in the child package java… here is a solution to the problem.

Import the super package in the child package java

Sorry, this is a Java newbie issue.
Does it make sense to create a child package that needs to import the “super” package?
It’s possible, but is it something that is usually done/logical?

Thank you.

EDIT: The other way around? Import a package whose child packages?

Solution

There is no such thing as a “child package” in Java.

Although com.example.some and com.example.some.thing

appear to be related (and the reality is that thing is likely to be a subdirectory of com/example/some), there is no parent/child relationship between them.

They are just two separate packages. If you want to use something from one package in another package, you must import or fully qualify the name.

Related Problems and Solutions