Thread View: aus.computers.java
2 messages
2 total messages
Started by someguy
Mon, 22 May 2000 00:00
help with arrayList urgent
Author: someguy
Date: Mon, 22 May 2000 00:00
Date: Mon, 22 May 2000 00:00
18 lines
1782 bytes
1782 bytes
greetings I have created an arraylist, which i have used to store objects of a purpose desinged class that holds a string and integer, and the toString returns both in a string "ie return(myString +myInteger);". I would like to know how to access the methods of my class from the arraylist. ie myArrayList.get(index).someMethodFromMyClass Interstingly enough, i can create new objects and add them to my list. I can get the values of these objects, but i cant invoke methods built into them to modify their values. The reason i have used arraylist is so that i dont have define the size of the arraylist - and for what i am doing this is an advantage. However if you have any better ideas then i would be glad to hear them. Please if you know how i can access these method i would appreciate it.
Re: help with arrayList urgent
Author: Steve Strongheart
Date: Mon, 22 May 2000 00:00
Date: Mon, 22 May 2000 00:00
36 lines
2176 bytes
2176 bytes
sumguy ~
You need to cast the java.lang.Object returned from myArrayList.get(int)
into an Object that has the desired method.
(myClass) myArrayList.get(int).someMethod()
assuming the Object is castable to myClass and that myClass contains
#someMethod()
~S~
someguy <someguy@somewhere.com> wrote in message
news:958986598.802617@brs.ihug.com.au...
> greetings
>
> I have created an arraylist, which i have used to store objects of a
purpose
> desinged class that holds a string and integer, and the toString returns
> both in a string "ie return(myString +myInteger);". I would like to know
> how to access the methods of my class from the arraylist.
>
> ie myArrayList.get(index).someMethodFromMyClass
>
> Interstingly enough, i can create new objects and add them to my list. I
> can get the values of these objects, but i cant invoke methods built into
> them to modify their values.
>
> The reason i have used arraylist is so that i dont have define the size of
> the arraylist - and for what i am doing this is an advantage. However if
> you have any better ideas then i would be glad to hear them.
>
> Please if you know how i can access these method i would appreciate it.
>
>
>
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads