Jump to content

Extract last variable from object

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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...