So I have something like the following:
public class Enclosing<T extends Comparable<T>> {
// non-relevant code snipped
public class Inner {
private T value;
public Inner(T t) {
value = t;
}
}
}
Everything compiles and the world is happy. However, whenever I try to create an instance of Enclosing.Inner
as follows, I can't:
new Enclosing<Integer>.Inner(5);
The following error happens:
Cannot allocate the member type
Enclosing<Integer>.Inner
using a parameterized compound name; use its simple name and an enclosing instance of typeEnclosing<Integer>
.
It is important to note that I cannot make the inner class static
, because it contains a field of type T
.
How can I work around this?