DEV Community

Discussion on: Can I import local class files in Java, like you can Python?

Collapse
 
siy profile image
Sergiy Yevtushenko

There is no notion of "current path" in regard to package structure in Java. Nor there are any parent-child relationship. In other words, every single package is independent and should be specified with the complete package name starting from the root. So, if you have package foo.bar and class within this package need to import some class from subpackage called localfolder (as in your example), you need to specify full import path: foo.bar.localfolder.LocalClassFile. You also can import nested classed from classes, for example foo.bar.localfolder.LocalClassFile.NestedClass.

Collapse
 
baenencalin profile image
Calin Baenen

Thank you! This is exactly what I'm looking for, it really helps with a "special prohect".

Here's a teasing hint: Interpreted language.

Again, thanks for the help.
Cheers.