I have a list in a Data Object in java which houses data retrieved from a database, be it multiple or single rows. I retrieve the List from the BO and dump it into a temporary list so that I can iterate over it to extract Data. When I just check the size of the list after doing the first assignment, everything is going on fine, but when I try and iterate over the list in a for loop, its size was being reduced. I was testing with two rows of data in the list, but in the loo, its size always used to be one. And the funny part is, I have used this logic in many places many times, but in this one Business Process in which I was writing this, it behaved very erratically. Any on has any leads on this? Here is a sample code
List temp = new ArrayList();
temp = dummyBO.getList(0) // Retrieves the List at index 0 from the BO
//Imagine the list has 2 rows of data. This prints the size as 2
System.out.println("size: "+temp.size());
System.out.println("Contents: "+temp.get(0);
System.out.println("Contents: "+temp.get(1);
//This is where the List starts behaving erratically
**for(int i=0;i<temp.size();i++){
System.out.println("size: "+temp.size()); //here the size is displayed as 1
System.out.println("Contents: "+temp.get(i); // here only the data at index 0 is shown
}**
P.S. This java code is written in the snippet section in IBM WID 6.1