Im getting an ArrayIndexOutOfBounds Exception, pl help

public static boolean isSOrt(int N, int[] arr) {

            if (N == 0) {

return true;
}

            if(arr[N] < arr[N-1]) {
                return false;

            }

            boolean check = isSOrt(--N, arr);
            return check;



        }
        public static void main(String args[]) {
            // Your Code Here

Scanner sc = new Scanner(System.in);
int N = sc.nextInt();

            int arr[] = new int[N];
            System.out.println("Enter total vals");
            for (int i = 0; i < N; i++) {

arr[i]=sc.nextInt();
}
boolean retval=isSOrt(N,arr);
System.out.println(retval);
}

    }

Hi @rdadhich,
You cannot pass N here as boolean retval = isSort(N,arr) … you should pass N-1 instead of N as arr[N] is not defined for array of size N . for example arr[2] is not defined for array of size 2 . Only arr[0] and arr[1] are defined. If there is any other problem please copy the code on ide.codingblocks.com and save it and then send the url as the code attached is not understandable.