N
nooneinparticular314159
I am trying to recover an integer from an arraylist:
ArrayList pathlist = new ArrayList();
pathlist has previously been populated with integers:
public void AddEdgeAndNodeToPath(int e, int n) {
pathlist.add(e);
pathlist.add(n);
}
Now I want to extract them. But when I try to do this:
int counter = 0;
int x;
for(counter = 0; counter < (pathlist.size()); counter++) {
x = (int) pathlist.get(counter);
}
it complains that I am trying to convert an Object to an int. Are my
ints forever trapped inside the ArrayList as objects? If not, how can
I get them out and turn them back into ints? The fate of the world may
rest upon your reply!
Thanks!
ArrayList pathlist = new ArrayList();
pathlist has previously been populated with integers:
public void AddEdgeAndNodeToPath(int e, int n) {
pathlist.add(e);
pathlist.add(n);
}
Now I want to extract them. But when I try to do this:
int counter = 0;
int x;
for(counter = 0; counter < (pathlist.size()); counter++) {
x = (int) pathlist.get(counter);
}
it complains that I am trying to convert an Object to an int. Are my
ints forever trapped inside the ArrayList as objects? If not, how can
I get them out and turn them back into ints? The fate of the world may
rest upon your reply!
Thanks!