adding to an arrayList

Hi there,

I'm trying to add an integer to my arrayList but I can't do it b/c the arrayList is defined as holding my user-defined object type...I couldn't even create an arrayList to hold integers. Here's what I mean:

ArrayList<Polygon> sourcePatch = new ArrayListPolygon();

sourcePatch.add(targetPoly);

*****when I try to add targetPoly to the list, I get an error saying it has to be type Polygon instead of type Integer. How do I get around this?

[486 byte] By [jjmclella] at [2007-11-27 11:06:38]
# 1

Either change targetPoly to be of type Polygon or change the ArrayList to accept integers instead of polygonsList<Integer> sourcePatch = new ArrayList<Integer>();

dwga at 2007-7-29 13:16:46 > top of Java-index,Core,Core APIs...
# 2

haha, thanks a lot...so simple. I thought I couldn't define an arrayList as type integer b/c I was trying this:

ArrayList<int> sourcePatch = new ArrayList<int>;

yeah, I'm new. thanks though...lesson learned

jjmclella at 2007-7-29 13:16:46 > top of Java-index,Core,Core APIs...