在java中删除2D arraylist中的特定行

时间:2013-02-25 18:57:12

标签: java arraylist

我想从2D arraylist中删除一个特定的行,该行将被下一行替换。我写了以下代码:

Collection<?> c = joint_mat.get(row); joint_mat.get(row).removeAll(c);

此代码正在删除行的元素,但不会将其替换为下一行。输出如下:

[0.6,0.608,0.608,0.628,0.608],

[0.6,0.6,0.6,0.608,0.608],

[0.6,0.652,0.6,0.612,0.608],

[],

[0.612,0.632,0.608,0.604,0.608],

[0.6,0.604,0.604,0.62,0.62],

1 个答案:

答案 0 :(得分:0)

这个怎么样:

joint_mat.remove(row);

P.S。一个更简单的方法来做你正在做的事情,清除行上的arraylist的内容,是这样的:

joint_mat.get(row).clear();