We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Im tring to make an ArrayList for object and i was struggling. I looked it up and i saw people using
ArrayList <object> object = new ArrayList <object>();
void draw() {
for (int i=0; i<object.**size**();i++) {
object.**get**(i).draw();
}
}
people said that these are functions that ArrayList uses that Array doesnt. when i tried this it didn't work and said that "the function get(int) does not exist". i want to make an ArrayList that adds 12 of the same object.
Answers
@cloudi --
Don't give your list instance the exact same name as the class it is based on. Here are my pets, a list made out of several Cat objects:
Try starting with the working example of an ArrayList of objects from the reference documentation:
Notice that it uses a capitalized class ("Particle") and a different list name ("particles").
@jeremydouglass says
But the entire truth is, that is exactly what is causing the problem.
class name must not be the same name as your ArrayList
Class Name in Capitals
one object small letters, singular
ArrayList, small letters plural
.
continued here (why!?)
https://forum.processing.org/two/discussion/20155/array-problem