m为去重后的长度
int[] arr = { 3, 5, 5, 6, 7, 7, 8, 8, }; int m = 0; for (int i = 1; i < arr.length; i++) { if (arr[m] != arr[i]) { arr[++m] = arr[i]; } }