/* package whatever; // don't place package name! */import java.util.*;import java.lang.*;import java.io.*;/* Name of the class has to be "Main" only if the class is public. */class Ideone{ public static void main (String[] args) throws java.lang.Exception { int[] a = {1,2,4,5}; System.out.println( Arrays.toString(reverseArray(a))); } public static int[] reverseArray(int[] nums){ int begin = 0; int end = nums.length -1; while(begin < end){ swap(nums, begin++, end--); } return nums; } private static int[] swap(int[] nums, int begin, int end){ int temp = nums[begin]; nums[begin] = nums[end]; nums[end] = temp; return nums; }}