public static int search ( float [ ] floatArray , float value , int occurrence ) { if ( occurrence <= 0 || occurrence > floatArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < floatArray . length ; i ++ ) { if ( floatArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the float array and return the index of the first occurrence from the beginning of the array .