top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: Does importing a package imports the subpackages as well?

–2 votes
504 views

e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?

posted Mar 26, 2014 by Prachi Agarwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Not in Java., and not in python....Don't know about other languages :). In C and C++ there is some other mechanism

1 Answer

0 votes

No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it's subpackage.

Credit: http://www.indiabix.com/technical/java-basics/5

answer Mar 26, 2014 by Luv Kumar
...