假设一个类的定义如下:
public class foodFactory{
protected EList<food> Basket;
public List<food> getBasket(){
return Basket;
}
}
当我尝试运行它时,以下会引发异常:
foodFactory factory = new foodFactory();
ArrayList<food> foodbasket;
foodbasket = (ArrayList<food>)getBasket();
我不明白为什么。我没有正确投射吗?