I would like some variant of this code to compile in java.
class X
{
List<X> getvalue(){...};
}
class Y extends X
{
List<Y> getvalue(){...};
}
Javac (1.6) returns an error because List<Y> and List<X> are not compatible.
The point is that I would like the compiler to recognize that List<Y> is a compatible return type to List<X> if Y is a subtype of X. The reason I want this is to simplify the use of a user-defined factory class.
Note: This question is somewhat like this question but for java.