In an array list, when new variables are added using
pointList.add(i , coord);
the new variable gets added and as well as replaces the existing values with new one.
how to stop these replacing variables ?
for(int i=0;i<coordinateArray.length();i++)
{
brokenArray= coordinateArray.getJSONObject(i);
x=brokenArray.getInt("x");
y=brokenArray.getInt("y");
Log.d("x", " "+i+ " "+x );
Log.d("y", " "+i+ " "+y );
coord.set(x, y);
pointList.add(i , coord);
Log.d("pointList", pointList.toString());
}
This is the bug.
You are setting the value in the loop to the same object.
Create the coord object inside the loop and add it.