Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing / inserting objects in ListArray 1

Status
Not open for further replies.

trium123

IS-IT--Management
Apr 8, 2005
15
GB
Hi All.
I have a List of 100 objects of which each have a string and two integer values
If I wanted to access the first object in the list and change one of the integers from a 5 to 10 then how could i do this?
I have tried using memberList.add(0,aValue); but i get the error that the add method cannot be found.
What am i doing wrong?
Thanks and regards.
Sam.
 
First you need to retrieve the Object from the List and then update the value.

Something like

Code:
Object obj = theList.get(0);
((YourObject)obj).methodThatSetsValue(yourValue);

Cheers,
Dian
 
Thanks, this solved my problem on the other thread!

I did it this way:

MyObject mo = (MyObject)(data.get( row )) ;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top