Could someone help me? I do not know why I am getting the below compile error since the class "secrow" implements Comparable
fw_generic3.java:92: error: no suitable method found for binarySearch(secrow,secrow)
int x0 = Collections.binarySearch(a,srBegin);
method Collections.<T#1>binarySearch(List<? extends T#1>,T#1,Comparator<? super T#1>) is not applicable
(cannot instantiate from arguments because actual and formal argument lists differ in length)
method Collections.<T#2>binarySearch(List<? extends Comparable<? super T#2>>,T#2) is not applicable
(no instance(s) of type variable(s) T#2 exist so that argument type secrow conforms to formal parameter type List<? extends Comparable<? super T#2>>)
where T#1,T#2 are type-variables:
T#1 extends Object declared in method <T#1>binarySearch(List<? extends T#1>,T#1,Comparator<? super T#1>)
T#2 extends Object declared in method <T#2>binarySearch(List<? extends Comparable<? super T#2>>,T#2)
no suitable method found for binarySearch(obj,obj)
Well, basically, the compiler is complaining that it can't find a binarySearch() method that takes an array and an object type. Can you show us where in the JavaDoc that such a method should exist? And note, a List object and an array object are not the same thing.
Ryan Chidley wrote:Could someone help me? I do not know why I am getting the below compile error since the class "secrow" implements Comparable...
I think everyone else has covered your basic problem, but here are a few observations for you:
1. You've written a fabulous amount of code, and a lot of it is redundant, which suggests to me that you haven't planned it BEFORE you started coding.
2. Classes start with a CAPITAL letter.
3. Your try/catch blocks and ErrorProcedure method (which should be 'errorProcedure') are all redundant, and vastly inferior to Java's own error handling - which is to display a Stack trace. Now it's possible that you were told to do it this way; but it's a crappy design.
Just have your fw_generic3 (which, again, should be 'fwGeneric3') throw IOException.
4. You could help yourself (and us) out a lot by giving your fields (and methods) proper names. Programs are designed to be read by humans, and an array called 'a' or an int called 'x0' doesn't mean a darn thing to anyone reading yours.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here