Getting an int when using Comparable object
Integer indexOf = new Integer( 5 ); really isn't doing anything.
Any suggestions?
import java.lang.*;
public class BinaryIndex{
public static void main ( String args[] ){
String objArray[] = { "a", "c", "e", "f", "g", "h", "i" };
String searchObj = "c";
binarySearch( objArray, searchObj);
System.out.println("Return the index of the insert point." );
System.out.println( "End of program" );
}
public static int binarySearch( Comparable[] objArray, Comparable searchObj )
{
int low = 0;
int high = objArray.length - 1;
int mid = 0;
Integer indexOf = new Integer( 5 );
while (low <= high )
{
mid = ( low + high ) / 2;
if (objArray[mid].compareTo( searchObj) < 0 )
low = mid + 1;
else if ( objArray[mid].compareTo( searchObj ) > 0 )
high = mid - 1;
else
return mid;
System.out.println( indexOf.intValue());
}
// item not found
System.out.println( "Item Not Found" );
return -1;
}
}

