Say I have the following:
public class A {
//stuff
public class B implements I {}
}
public interface I {}
public class Foo {
int bar(I i) {}
}
Now why does Java give me a build error of ‘not applicable for type…’ when I try to pass an instance of B to Foo.bar() inside the body of class A?
Is the inner class not considered a proper implementation of I because it is contained inside a top-level class?
Cheers, Dave.
You need a Instance of class A, before you can create a instance of object B (because B is a inner class of A).
Try this code: