• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is problem in method Compareto ?  RSS feed

 
chibi riko
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is problem in method Compareto ?
Capture-d-cran-2016-11-12-13.18.29.png
[Thumbnail for Capture-d-cran-2016-11-12-13.18.29.png]
Capture-d-cran-2016-11-12-13.19.22.png
[Thumbnail for Capture-d-cran-2016-11-12-13.19.22.png]
Capture-d-cran-2016-11-12-13.19.57.png
[Thumbnail for Capture-d-cran-2016-11-12-13.19.57.png]
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know, is there a problem? I just see three screenshots.

I'm guessing that you don't get the result printed out (but my crystal ball is broken so I don't know for sure). That could have a couple of reasons. Some of the most likely:
- The list is not sorted. Collections.binarySearch only works on sorted lists.
- The ID is a Double or Float (which again is a big guess). Computers can't handle floating point numbers well (we have an FAQ about it, can someone find it?). That means that the comparison of one 2.11 might not give an equal comparison with another 2.11. Use BigDecimal or String instead.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!