I have been trying this using two arrays, and it was successful but the in-place reversing was bit confusing for me. if you can help, that will be great public class reverseOfAnArray {
int[] reverseCal(int arr[]){
int i,j=0;
for (i=arr.length;i>0;i--,j++){
arr[j]=arr[i-1];
}
return arr;
}
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int size,i=0;
System.out.println("enter the size of your array");
size=scan.nextInt();
int originalArray[]=new int[size];
System.out.println("Enter the elemets in the array");
for (i=0;i<size;i++){
originalArray[i]=scan.nextInt();
}
reverseOfAnArray cal=new reverseOfAnArray();
System.out.println("reverse of the given array is
\n"+Arrays.toString(cal.reverseCal(originalArray)));
}
}