我有一个 ArrayList,初始化如下:
public static List<int[]> items = new ArrayList<int[]>();
我像这样向它添加项目:
items.add(new int[] {2,0,1,0,1});
我可以更改 ArrayList 中已有数组的特定条目吗(例如:索引 0 处的 2),或者每次都必须使用 items.set()
重新创建数组?
最佳答案
你可以这样做:
int[] array = items.get(0);
array[0] = <new value>;
关于java - 如何替换数组列表中数组中的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32040724/