Re: Trouble with ArrayList



Lawrence wrote:
Item getitem = items.get(0);

You need to cast the returned object to the expected type:

Item getitem = (Item) items.get(0);

Alternatively, if you're using Java 5.0 you could do it with generics:

private ArrayList<Item> items;
items = new ArrayList<Item>();
items.add(item);
Item getitem = items.get(0);

.