Hi,Please have a look at he following code:
import java.util.*;
public class Basket<E>
{
List<Red> red;
List<Apple> applw;
private E element;
public void setElement(E x)
{
element=x;
}
public E getElement()
{
return element;
}
public <A extends Apple> List<? super Apple> insertRipe(A a,Basket<? super Apple> basket)
{
basket.setElement(new Red());
return red;//Line 1
}
public static void main(
String[] args)
{}
}
class Fruit{}
class Apple extends Fruit{}
class Red extends Apple{}
**********************************
Th code returns an error on 'Line 1'.The return type of the method is '? super Apple' so according to me it can return 'red'.
Please let me know where is the issue,
Thank you.