Kat*_*ona 12
您可以使用List#subList(int,int):
List<Integer> list = ...
list = list.subList(10, list.size()); // creates a new list from the old starting from the 10th element
Run Code Online (Sandbox Code Playgroud)
或者,由于subList创建了一个视图,每个修改都会影响原始列表,这可能更好:
List<Integer> list = ...
list.subList(0, 10).clear(); // clears the first 10 elements of list
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10119 次 |
| 最近记录: |