ArrayList question - can add String but not int
797160Jan 19 2011 — edited Jul 24 2013I"m a little confused on something with ArrayLists. I'm trying to add an int to the ArrayList
Suppose I have:
int myInt = +<some value>+
String myString = +<some value>+
ArrayList myAL= new ArrayList(0);
myAL.add(myInt);
myAL.add(myString);
However, when I compile (using java 1.4.2), I get a compile error for the method add when it's passed an int, so I have to do this instead:
myAL.add(Integer.toString(myInt));
Is there some way I can store these integer value in my ArrayList as int's without converting them to String?