I have a need create an ArrayList to collect positions of some points.
ArrayList<int[]> collection = new ArrayList<int[]> ;
//the position has 2 coordinations.
int[] location = new int[2]
//add first position a,b
location[0] = a;
location[1] = b;
collection.add(location);
//add second position c,d
location[0] = c;
location[1] = d;
collection.add(location);
When I try to display the collection, all the elements inside are exactly the same as the last one was added (in this case: [c,d])
How do I add the element to my ArrayList properly in this case ? Thank you very much
locationint array. Just callcollection.add({a,b});andcollection.add({c,d});