cancel
Showing results for 
Search instead for 
Did you mean: 

Read and write values fo collection

Former Member
0 Kudos

Hi Experts ,

Pls guide me in resolving the below issue

1. I have a collection XX with 5 columns (Q1 , Q2,Q3,Q4,Q5) .

On a particular condition , I'm trying to add new rows .

consider I have added 2 rows .

//valu=2

for(int j =0;j<valu;j++){

annual.add( newMember );

}

}

On adding 2 rows , I'm trying to read first row and trying to set value for Q1

savingsIter = annual.iterator();

while (savingsIter.hasNext())

{

member = savingsIter.next();

firstRow=annual.get(0);

firstRow.set("ERS_Q1", Qu1);

}

On trying this , automatically Q1 of 2nd row is auto-populated with value updated in 1st row

Pls suggest me where i'm going wrong

THANKS IN AdVANCE

Tayi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

From what you have mentioned above, it looks like You have created one collection object and have added the same collection object n number of times. Hence any change made in one of the objects is reflected in all the objects.

Place the code to create the collection object and the code to add the collection object(which u have already done) inside the looping construct(in ur case the for loop). This will solve ur problem.

Hope this helps.

Regards

Immanuel

Former Member
0 Kudos

Hi Immual,

Thanks for your reply . iT resovled my prbm . How to iterate on collection starting from 3rd row . Any idea

THANKS IN ADVANCE

Tayi

Former Member
0 Kudos

retrieve the collection. Use a normal for loop and and skip the first 2 rows.

say colln is the collection

size=colln.size();

for(i=2;i<size;i++){

collnBean=colln.get(i);

//perform the required operations on colln bean

}

Regards,

Immanuel

Answers (1)

Answers (1)

Former Member
0 Kudos

Thank you . It solved my problem