Preview:
public class Main {

        public static void main(String[] args) {
            int [] arr =  {1,2,3,4,5,6};
            System.out.println(findEl(arr,6, arr.length-1));
        }

        public static int findEl(int [] arr,int target, int index) {
            if (index== arr.length){
                return -1;
            }
            if(arr[index]==target){
                return index;
            }else{


            return findEl(arr, target, index+1);
            }
        }

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter