I declared a new interface (foo)in the default package. When I created a new class in a different package, which implements this foo interface,I got an error message saying foo is not resolved although I did import the interface. However, if I declared the same interface in a proper package(bar) and then import it like this: import bar.foo then it works. why is it? Does anyone know?
SCJP 5.0 <br />-> Change job<br />-> Decide another cert to do
Since one of the newer versions of Java (I think since Java 5) you cannot import classes or interfaces from the default package anymore.
In older versions of Java, it was possible to do that, like this:
But that feature has been removed - you'll get an error message if you try to do this in Java 5 or 6. You must put your interface in a package other than the default pacakge if you want to be able to use it in a different package.