Case error in my code

public static int find(int[] arr, int d,int i){

    if(i>arr.length-1){
        return -1;

    }
    if(arr[i]==d){
            return i;

        }
        else{
            return find(arr,d,i+1);

        }

}

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();


    int[] arr = new int[n];
    for(int i =0;i<arr.length;i++){
        arr[i] = sc.nextInt();

    }
    int digit = sc.nextInt();
    int result = find(arr,digit,0);
    System.out.println(result);
}

@susheelverma444_eac4c9e22456b89c your code is not giving any error it is giving you WRONG ANSWER. It is because you need to check from last if the element is there or not.for example :
5
6 9 3 9 0
9
This input should give output 3
but your code is giving 1 which is the occurrence from start. So cure this problem.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.