Getting a parameter from an object in an ArrayList
in
Programming Questions
•
1 years ago
Is there an easier way to get a single parameter from a given object in an ArrayList? Right now I'm doing it like this:
xpos = getXpos(id - 1) + 1;
int getXpos (int listnum) {
MyClass foo = (MyClass) mylist.get(listnum);
return foo.xpos;
}
I'd rather do it like this, though:
xpos = mylist[id -1].xpos + 1;
Any way?
1