title: Return all instance one variables in one call
body: <p>I have this class that serves as a container which I will use the instance variable for processing later</p>
  
  <pre><code>class Data{
      static int counter= 0;
      boolean boolean1;
      String string1;
  
      public Data() {
          counter++;
      }
  }
  </code></pre>
  
  <p>And I have this method that sets the values of Data</p>
  
  <pre><code>public Data setData()
  {
      Data data = null;
      for (int i = 0; i &lt; somecoutnerhere; i++) {
  
          Data = new Data();
          Data.boolean1 = some boolean put here;
          Data.string1 = "some string to be put here";
      }
  
      return ProcessData(Data);
  }
  </code></pre>
  
  <p>I also have this class ProcessData that will make use of Data and will construct the response</p>
  
  <pre><code>private class ProcessData
  {        
      private final Map&lt;String, List&lt;?&gt;&gt; map = new HashMap&lt;String, List&lt;?&gt;&gt;();
      int counter;
  
      public ProcessData(Data data)   
      {
          map.put("boolean1", data.boolean1);
          map.put("String1", data.string1);
          counter = data.counter;
      }
  
       public String someMethodToGenerateReturnData(){
       // some code here to make use of the Data collected. Will basically use map to construct the return String
       }
   }
  </code></pre>
  
  <p>My problem is that I couldn't figure out how can I return all the instance variables created on the for-loop for Data on setData(). Any thoughts?</p>