java数组反转
private static int[] extracted(int[] arr) {
for (int start = 0, end = arr.length - 1; start < end; start++, end--) {
arr[start] = arr[start] ^ arr[end];
arr[end] = arr[start] ^ arr[end];
arr[start] = arr[start] ^ arr[end];
}
return arr;
}
public static void main(String[] args) {
int[] arr = {11,22,33,44,55};
int[] arr1 = extracted(arr);
for (int i = 0; i < arr1.length; i++) {
System.out.println(arr[i]);
}
}
55
44
33
22
11进程已结束,退出代码0
评论 (0)