I have an ArrayList which has objects of Coords which are x and y:
ArrayList<Coords> positionsArrayList = new ArrayList<>(values);
class Coords {
int x;
int y;
public boolean equals(Object o) {
Coords c = (Coords) o;
return c.x == x && c.y == y;
}
public Coords(int x, int y) {
super();
this.x = x;
this.y = y;
}
public int hashCode() {
return new Integer(x + "0" + y);
}
}
Now i want to extract this x and y in form of 2D array double[][].
Just like
double[][] vector={{0,0},{1,1},{2,2}}
I have tried this code:
for (Coords value : positionsArrayList) {
positions = new double[][]{{value.x, value.y}};
}
But it does enter only the last entry. New to java please help