I m new to java algos ,plz hep me to fix the my binary search program in java. 
Its giving wrong indexes. 


import java.io.IOException;
    
    class Search{
    private int min;
    private int max;
    private int curr;
   
    public Search(int[] ar){
    min=0;
    max=ar.length-1;
    curr=(min + max)/2;
    }
   
    public void find(int[] arr,int f){
    int i=0;
    while(i==0){
    if(f>arr[curr]){
    min=curr;
    curr=(min+max)/2;
    System.out.println("f>arr "+curr );
   
   
    }
    else if(f<arr[curr]){
    max=curr-1;
    curr=(max+min)/2;
    System.out.println("f< curr"+ curr );
   
   
    }
   
    System.out.println("found Element at index"+ curr );
   
   
    }
   
    }
    }
   
   
    
    public class Main_class{
    public static void main(String args[]) throws IOException{
    int[] array ={1,2,3,4,5,6,7,8,9,10};
    Search obj = new Search(array);
    obj.find(array,4);
   
    }
   
    }