Article View: aus.computers.java
Article #629Re: working with arraylist
From: Brad Long
Date: Tue, 20 Jun 2000 00:00
Date: Tue, 20 Jun 2000 00:00
36 lines
1848 bytes
1848 bytes
MyClass obj = new MyClass(); ArrayList a = new ArrayList(); a.add(obj); ((MyClass)a.get(0)).myMethod(); James Moey wrote in message <394EBA81.64C3C46A@igelaus.com.au>... >someguy wrote: > >> 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. >> >> Please if you know how i can access these method i would appreciate it. > >I think you need to "cast" the object back to the form you need before you can >call any of it's method. > > >from >James >
Technical Details
Message-ID:
<8inpff$6sb$1@bunyip.cc.uq.edu.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<958984148.685705@brs.ihug.com.au> <394EBA81.64C3C46A@igelaus.com.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fdb77,3ab74ead81e4ec2b X-Google-Attributes: gidfdb77,public X-Google-Thread: 10d6db,3ab74ead81e4ec2b X-Google-Attributes: gid10d6db,public X-Google-Thread: 113ae9,3ab74ead81e4ec2b X-Google-Attributes: gid113ae9,public From: "Brad Long" <bjl@uq.net.au> Subject: Re: working with arraylist Date: 2000/06/20 Message-ID: <8inpff$6sb$1@bunyip.cc.uq.edu.au> X-Deja-AN: 636776891 References: <958984148.685705@brs.ihug.com.au> <394EBA81.64C3C46A@igelaus.com.au> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: news@uq.edu.au X-Trace: bunyip.cc.uq.edu.au 961505583 7051 203.100.28.54 (20 Jun 2000 12:53:03 GMT) Organization: University of Queensland NNTP-Posting-Date: 20 Jun 2000 12:53:03 GMT Newsgroups: aus.computers.java,comp.lang.java.advocacy,comp.lang.java.help