title: Why does For loop duplicates values
body: <p>I am trying to get some values from the server, everything is working fine however for some reason I receive the value as a duplicate, the server contains of 3 keys and values however in my code it shows 6 keys and values, please advise what could be causing this.</p>
  
  <p>FirstActivity.java</p>
  
  <pre><code>public void getGifts() {
      Communicator.getInstance().on("initializeRoom", new Emitter.Listener() {
  
          @Override
          public void call(Object... args) {
              JSONDictionary response = (JSONDictionary) args[0];
              String str = response.get("data").toString();
              try {
                  JSONObject dataJSo = new JSONObject(str);
                  JSONArray giftsData = dataJSo.getJSONArray("gifts");
                  for (int i = 0; i &lt; giftsData.length(); i++) {
                      JSONObject gifts = (JSONObject) giftsData.get(i);
                      giftsId = (Integer) gifts.get("id");
                      giftsPrice = (Integer) gifts.get("price");
                      giftsMinLevel = (String) gifts.get("minLevel");
                      giftsUrl = (String) gifts.get("urlFile");
                      giftsArray.add(new GiftsModel(giftsId, giftsPrice, 
                                      giftsUrl, giftsMinLevel));
  
                  }
  
                  Singleton.instance().cache = giftsArray;
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
  
      });
  
  }
  </code></pre>
  
  <p>SecondActivity.java</p>
  
  <pre><code>public class SecondActivity{
  
        ArrayList&lt;GiftsModel&gt; giftsArray = Singleton.instance().cache;
  
        //And some code
  
  }
  </code></pre>
  
  <p>Singleton.java</p>
  
  <pre><code>public class Singleton {
  private Singleton() {}
  
  static Singleton obj= null;
  public static Singleton instance() {
      if (obj == null) {
          obj = new Singleton();
      }
      return obj;
  }
  
  public ArrayList&lt;GiftsModel&gt; cache;
  }
  </code></pre>