[Solved] how to use function correctly in java


thanks to all…..the thing which i dont know was – during a function call if i want to pass an array(arr[]) as argument then i just need to pass its name(arr) as argument not the square brackets([]) along with it. Here is my new optimized error free code which has been submitted successfully.

import java.util.*;
import java.lang.*;
import java.io.*;
class GFG
 {
    public static void main (String[] args)
     {
         Scanner sc= new Scanner(System.in);
         int t,n,i,left,right,leftid,rightid;
         t=sc.nextInt();
         while(t!=0){
             n=sc.nextInt();
             int arr[]=new int [n];
             for(i=0;i<n;i++){
                 arr[i]=sc.nextInt();
             }
             left=0;right=n-1;
             leftid=funcleft(arr,n,left,right);
             rightid=funcright(arr,n,left,right);
             System.out.println(arr[leftid]+" "+(rightid-leftid+1));
             t--;
         }
     }
     static int funcleft(int arr[],int n,int left,int right){
         int mid=(left+right)/2;
         if(mid==0)
         return mid;
         if(arr[mid]==arr[mid+1]&&arr[mid]!=arr[mid-1])
         return mid;
         if(arr[mid]==arr[mid-1])
         return funcleft(arr,n,left,mid-1);
         if(arr[mid]-arr[0]<mid)
         return funcleft(arr,n,left,mid-1);
         else
         return funcleft(arr,n,mid+1,right);
     }
     static int funcright(int arr[],int n,int left,int right){
         int mid=(left+right)/2;
         if(mid==n-1)
         return mid;
         if(arr[mid]==arr[mid-1]&&arr[mid]!=arr[mid+1])
         return mid;
         if(arr[mid]==arr[mid+1])
         return funcright(arr,n,mid+1,right);
         if(arr[mid]-arr[0]<mid)
         return funcright(arr,n,left,mid-1);
         else
         return funcright(arr,n,mid+1,right);
     }
}```

solved how to use function correctly in java