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.
为什么在ArrayList有这样的方法而在并发兄弟上却没有?
ArrayList
受保护的无效删除范围(int fromIndex,int toIndex)
只是好奇它不是根本我可以解决它。
您可以间接执行此操作。
List<Integer> ints = new CopyOnWriteArrayList<Integer>(); for (int i = 0; i < 10; i++) ints.add(i); ints.subList(4, 7).clear(); System.out.println(ints);
印刷
[0, 1, 2, 3, 7, 8, 9]