ArrayLists - Getting index of parameters of objects of ArrayLists.
I have this borderline difficult HW assignment that introduced ArrayLists about a lesson back from the one I am on now. Currently I am having difficulty doing something (and wording) to make the script work right. Lets say I have the following (example script):
Code :
ArrayList<ShapesV4> shapes = new ArrayList<ShapesV4>();
shapes.add(new ShapesV4(10, 5));
shapes.add(new ShapesV4(7, 1));
shapes.add(new ShapesV4(5, 2));
Except mine has one int and several Boolean statements as the parameters of the "new shapes object". I am currently trying to figure out how to get the element of the parameters of one of the shapes objects. From what I have figured out, sometihng like shapes.get(x) will only get the object and not the element of a parameter of one of those objects. I need to be able to iterate through the parameters of all those objects but I don't know how to set that up. I figured it would look something like shapes.get(0[1]) to get the number 5 of the first object. But obviously that isn't correct... What is the correct setup if someone is kind enough to answer?
Re: ArrayLists - Getting index of parameters of objects of ArrayLists.
Quote:
how to get the element of the parameters of one of the shapes objects.
You could do it in two steps.
1) get an Shapes object reference out of the ArrayList using the get method
2) use that object reference to call a Shapes class method.