Only the last added item gets printed
<pre><code>List &lt; Response &gt; Data = new ArrayList &lt; Response &gt; ();
Response object = null;

JSONObject documentRoot = new JSONObject(result);
JSONArray documentChild = documentRoot.getJSONArray("Main");
JSONArray allergyArray = null;
JSONArray vitalsArray = null;

for (int i = 0; i &lt; documentChild.length(); i++) {
    child = documentChild.getJSONObject(i);
    if (Condition1) {
        allergyArray = child.getJSONArray("Allergy");
    } else if {
        vitalsArray = child.getJSONArray("Vitals");
    }
}

object = new Response(); // POJO class

if (null != allergyArray) {
    for (int i = 0; i &lt; allergyArray.length(); i++) {
        object.setCap(allergyArray.getJSONObject(i).getString("Cap"));
        object.setRea(allergyArray.getJSONObject(i).getString("Rea"));
    }
}

if (null != vitalsArray) {
    for (int i = 0; i &lt; vitalsArray.length(); i++) {
        object.setName(vitalsArray.getJSONObject(i).getString("Name"));
        object.setMedic(vitalsArray.getJSONObject(i).getString("Medic"));
    }
}

Data.add(object);
</code></pre>

<p>Only the last added item gets printed, when i try to iterate and print the result. </p>

<pre><code>public void onLoadComplete(List &lt; Response &gt; item) {    
    for (int i = 0; i &lt; item.size(); i++) {
        Log.d("Get", item.get(i).getCap()); // I get only the last item which is added.
    }      
}
</code></pre>

<p>Why is my List Object passed to onLoadComplete function contains only the last item added to the POJO class.</p>
