When you do this
MyWebServiceRequest mywebService = new MyWebServiceRequest();
MyRequestType type= new MyRequestType ();
for(int i=0; i< 9; i++){
type.setA(1);
type.setB(2);
mywebService.add(type);
}
The line mywebService.add(type);
adds the object into list , no matter its state is changed or not or it is the same object. Because its a list and not a Map which do not allow duplicates.
So the count goes to 10 , now when you do
MyWebServiceRequest mywebService = new MyWebServiceRequest();
for(int i=0; i< 9; i++){
MyRequestType type= new MyRequestType ();
type.setA(1);
type.setB(2);
mywebService.add(type);
}
The code now makes a new object and add to list , but every object is different . The only difference in two snippets is , the Objects in the second snippet are not same , but in the first snippet its same but added 10 times.