public ArrayList<Integer> reverse(ArrayList<Integer> list) { for(int i = 0, j = list.size() - 1; i < j; i++) { list.add(i, list.remove(j)); } return list; }
remove(int index)
Removes the element at the specified position in this list. Return the element.
Appends the specified element to the end of this list.
Inserts the specified element at the specified position in this list.
时间: 2024-10-06 23:21:06