I am a newbie to Java development. I have a quick question regarding recursive imports in Java.
Lets assume Package \"pkg\" contains the following
There is no restriction on imports as you described in your original question (prior to the edit).
Let's assume you have the following Hierarchy:
pkg1
A.java
pkg1.pkg2
B.java
pkg1.pkg3
C.java
D.java
You are permitted to import any of the A.java, B.java, C.java, D.java, or combinations therein.
import pkg1.A;
import pkg1.pkg2.B;
import pkg1.pkg3.C;
import pkg1.pkg3.D;
The only caveat is that within class C, you can use class D without importing D explicitly because they share the same package.
However, a blanket statement like import pkg1.*
will not pull in the classes located further down the package hierarchy; you'd need to import each sub-package as well: import pkg1.pkg2.*
, etc. This is simply how the language is designed.