I’m trying to use the binarySearch method documented at the Java API Specification but my IDE, Eclipse (Helios), is not recognizing the signature.
My class, boiled down to its 2 data members and the method in which I’m trying to call the Arrays.binarySearch:
import java.util.Arrays; // Access Arrays class
public class SortedStringArrayList {
// member data
private String[] items;
private int size;
// methods
public int testBinSearch(String item) {
int index = Arrays.binarySearch(items, 0, size, item);
}
}
When I code in the method, Eclipse assumes I want a different signature and tells me:
The method binarySearch(int[], int) in
the type Arrays is not applicable for
the arguments (String[], int, int,
String)
The signatures for binarySearch it suggested as available were:

I’m very new to Java/Eclipse. Anyone know what the problem is?
You need to tell Eclipse to use Java 1.6 (under project settings). I’m guessing you’re on 1.5. 1.5 and older versions only have the basic version of
binarySearch, with nofromIndexortoIndex.If you want users with older JREs to be able to run your program, you could copy the
binarySearchimplementations from the 1.6 source and paste it into your own code.