title: Creating new instance of object in loop to add in list
body: <p>I am trying to add the object (JavaBean) into the list.</p>
  
  <pre><code>     MyWebServiceRequest mywebService = new MyWebServiceRequest();
       MyRequestType type= new MyRequestType ();
  
         for(int i=0; i&lt; 9; i++){
             type.setA(someDynamicValue);
             type.setB(someDynamicValue);
             mywebService.add(type);
         }
  </code></pre>
  
  <p>This creates only one object of (type), so it add same object 9 times with same data.</p>
  
  <pre><code> MyWebServiceRequest mywebService = new MyWebServiceRequest();
     for(int i=0; i&lt; 9; i++){
             MyRequestType type= new MyRequestType ();
             type.setA(someDynamicValue);
             type.setB(someDynamicValue);
             mywebService.add(type);
         }
  </code></pre>
  
  <p>This creates multiple objects, add 9 diff object with diff values . </p>
  
  <p>What if (for loop) create hundreds of objects instead of 9 in single loop , each and every time a request is made?
  So its dump in memory right?</p>
  
  <p>How to avoid this?</p>
  
  <p>Thanks in Advance. </p>