Re: Trouble with ArrayList
- From: trippy <silverbells@xxxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 15:54:17 -0600
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"
.
- References:
- Trouble with ArrayList
- From: Lawrence
- Trouble with ArrayList
- Prev by Date: Re: Obtain file path and file name using file chooser
- Next by Date: Re: understand the concept of interfaces
- Previous by thread: Re: Trouble with ArrayList
- Next by thread: wrong jai for Windows from Mac NetBeans build?
- Index(es):