1

Let's say I've created an array of objects SpecialResource via

ArrayList<SpecialResource> masterRes = new ArrayList<SpecialResource>();
masterRes.add(0, new SpecialResource(3,5,0,"Foo Bar"));
.........etc etc many more adds...

Let's say SpecialResource has a method calledgetMax()

How would I reference the getMax method of array index 0? Every permutation I've guessed at is giving syntax errors. masterRes<0>.getMax(), masterRes(0).getMax(), etc.

2 Answers 2

2

Well, actually, it's not an array, but a collection. And, in order to retrieve its items by index, you must use the get method:

masterRes.get(0).getMax();
Sign up to request clarification or add additional context in comments.

1 Comment

That's exactly what I needed. Thank you. This is a world of difference from python :)
0
masterRes.get(0).getMax();

Java/Android API document will help you.

http://androidappdocs.appspot.com/reference/java/util/ArrayList.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.