Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
除了手动遍历和将内容放入新数组之外,我还有其他选择来修改不可修改的列表吗?
一些开发人员选择以这种方式构建 API,而不是克隆 ..
许多集合接受另一个Collection作为构造函数参数。您可以执行以下操作:
Collection
List<T> mutable = new ArrayList<>(immutable);
然后只处理mutable收集。
mutable