我有一个具有s的对象,它们是x和y:ArrayListCoord
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);
}
}
现在我想以2D数组的形式提取这个x和y。就像double[][]
double[][] vector={{0,0},{1,1},{2,2}}
我试过这个代码:
for (Coords value : positionsArrayList) {
positions = new double[][]{{value.x, value.y}};
}
但它确实只输入最后一个条目。Java新手请帮忙
ibeautiful
慕田峪4524236
慕盖茨4494581
相关分类