File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes collections binarySearch: always return  1 ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "collections binarySearch: always return  1 ?" Watch "collections binarySearch: always return  1 ?" New topic
Author

collections binarySearch: always return 1 ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I am doing some Collections.binarySearch, but I find it will always return "1". In the coding below, no matter you search t1,t2, it always return "1", Where is the bug ?

THanks

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

The bug is in these two lines:Look very closely...
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Thanks. Yes, one copy-paste waste me 40 minutes....

Thanks
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Unit tests are your friend...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: collections binarySearch: always return 1 ?