• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error: no suitable method found for binarySearch(obj[],obj)

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

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)

// fw_generic3 class:


 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

Henry
 
Ranch Hand
Posts: 86
2
VI Editor Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As implied in above post, you have to change the line

to

or maybe use method binarySearch of class Arrays itself.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

HIH

Winston
 
Ryan Chidley
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the feedback.
reply
    Bookmark Topic Watch Topic
  • New Topic