I want to do this:
Foo<String> foo = new Foo<>(); Foo<String>.Bar fooBar = foo.new Bar(); fooBar.doSomething("this works!");
But then the first two lines in one line, such as:
Foo<String>.Bar fooBar2 = new Foo<>().new Bar(); fooBar2.doSomething("The above line gives: incompatible types. Required: Foo.Bar Found: Foo.Bar");
But the first line fails. I get:
incompatible types.
Requires: Foo.Bar
Found: Foo.Bar
Why is this?
public class Foo<T> { public class Bar extends SomeOtherClass<T> { public void doSomething(T t) { } } }
And the last class:
public class SomeOtherClass<T> { }
source share