Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

some.java

import A.A1.*;

Directory structure

  A

  |_A2

  |  |_some.java

  |_A1

     |_someother files and java files

Here the import statement is not working. Can someone tell me why?

1 Answer

0 votes
by (13.1k points)

I hope that A is not your current directory.

Packages work with directory hierarchies.

<curr-dir>

 |-A

 | |-A1

 | | |- Class1.class

 | | `- Class2.class

 | `-A2

 |   |-Class3.class

 |   `-Class4.class

 `-<other dirs>

Now if <curr-dir> is in your classpath then import A.A1.* will import Class1 and Class2

Related questions

0 votes
1 answer
asked Apr 15, 2021 in Java by Jake (7k points)
0 votes
1 answer
0 votes
1 answer
asked Mar 21, 2021 in Java by Jake (7k points)
0 votes
1 answer
asked Oct 17, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Oct 9, 2019 in Java by Anvi (10.2k points)

Browse Categories

...