class Test_Array3 {
public static void main(String[]args) {
int[] arr = {1,2,3,4,5};
print(arr);
reverse(arr);
}
public static void print(int[] arr) {
for (int x=0; x<arr.length/2; x++) {
int temp = arr[x];
arr[x] = arr[arr.length-1-x];
arr[arr.length-1-x] = temp;
}
}
public static void reverse(int[] arr) {
for (int i=0; i<arr.length; i++) {
System.out.println(arr[i]+" ");
}
}
} |
|