import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class ArrayReverse { // ArrayList 反转元素 // 双指针解法 // 出自 java.util.Collections#reverse public static void main(String[] args) { List list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7)); int size = list.size(); Integer x, y; for (int begin = 0, mid = size >> 1, end = size - 1; begin < mid; begin++, end--) { x = list.get(begin); y = list.get(end); list.set(begin, y); list.set(end, x); } System.out.println(list); } }