Well, as long as EList
is ot derived from ArrayList
, there must be a ClassCastException.
List<food> foodbasket = (List<food>) factory.getBasket();
Don't use ArrayList
, use the interface List
.
By the way, you should use the java naming conventions.
Classnames start uppercase. Valiables are lowercase.