I want to reverse an int array in java and this is the code but it throws an error arrayOutOfBound exception.
class reverse_number {
    public static void main(String[] args) {
        int ar[]={1,3,4,2};
        int ar1[]=new int[4];
        for(int i=0;i<ar.length;i++) {
            ar1[i++]=ar[ar.length-1];
        }
        for(int i=0;i<ar1.length;i++) {
            System.out.print(ar1[i]);
        }
    }
}
 
     
     
     
    