数组逆序输出

public class Shuzunixu {
public static void main(String arg[]) {
Array(new int[] { 1, 2, 3, 4, 5, 6 });
}

public static void Array(int arr[]) {
for (int start = 0, end = arr.length - 1; start < end; start++, end--) {
int a = arr[start];
arr[start] = arr[end];
arr[end] = a;
}
for (int k : arr)
System.out.println(k);
}
}

猜你喜欢

转载自www.cnblogs.com/Lovemeifyoudare/p/10304998.html