Jump to content

Extract last variable from object


justinbriggs1

Recommended Posts

Hey everyone, I am messing around with the arrayList class, and I am having a bit of trouble.arrayList utilizes an object buffer to keep track of the class elements. How do I extract the last variable from the buffer? This is obviously pretty easy if it is cast to an array, but I can't figure it out with an object.Also, is there a way to extract an object variable at a specified index?Thanks, really confused, any help would be appreciated.

Link to comment
Share on other sites

The ArrayList instance should make methods available to access that functionality. For example, you could use ArrayList.get() in conjunction with ArrayList.size().

Also, is there a way to extract an object variable at a specified index?
What do you mean?
Link to comment
Share on other sites

What he wants I presume is the object returned from the get method. The indexof(Obj elm) method will get you the location of the elm where elm is an Object you create and pass to it. Use the return value of this method as input into the ArrayList.get method and you will get the Object you want returned from there. You can use methods on Object like 'tostring' to convert an Object to something usefull.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...