Median of sorted arrays

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr1=new int[n];
int[] arr2=new int[n];

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

	}
	for(int i=0;i<n;i++){
		arr2[i]=sc.nextInt();
	}
	int med=median(arr1,arr2);
	System.out.println(med);
}
public static int median(int[] arr1,int[] arr2)
{
	int n=arr1.length;
	return median(arr1,0,n-1,arr2,0,n-1);
}
public static int median(int[] arr1,int l1,int h1,int[] arr2,int l2,int h2)

{

int mid1=(h1+l1)/2;
int mid2=(h2+l2)/2;
if(h1-l1==1)
return(Math.max(arr1[l1],arr2[l2])+Math.min(arr1[h1],arr2[h2]))/2;
else if(arr1[mid1]>arr2[mid2])
return median(arr1,l1,mid1,arr2,mid2,h2);
else
return median(arr1,mid1,h1,arr2,l2,mid2);

}
}

one testcase went wrong…plz correct my code where i went wrong

@karthik1989photos,

https://ide.codingblocks.com/s/269413 corrected code.
Error:
while comparing mid1 and mid2 don’t use array values. Just compare mid1 and mid2

in this code what is the use of bitwise operator

@karthik1989photos,
We are just dividing it by 2.

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.