Re: Trouble with ArrayList



In article <1164729017.173636.245310@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Lawrence took the hamburger meat, threw it on the grill, and I said "Oh
Wow"...

Im relatively new to Java and have started implementing an ArrayList
using:

private ArrayList items;

initialising it using:

items = new ArrayList();

adding to it using:

items.add(item); - where item is of class Item

the problem is when i am calling the Item from the arraylist:

Item getitem = items.get(0);


I get the error message: incompatible types - Item expected but Object
found.....


Any help would be great :D



Cast it to the type you need.

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

--
trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Aces High" -- Iron Maiden

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum, a pocketknife,
and a smile."

-- Robert Redford "Spy Game"



.