Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

compareTo( )

807569Sep 26 2006 — edited Sep 26 2006
Hi!
My compareTo method returns an ISBN string
How can I compare two strings?
public int compareTo(Object obj) {
   Book  b = (Book)  obj;
  if(isbn<b.getIsbn())
       return -1;
             else if(isbn>b.getIsbn())
       return 1;
   else
      return 0;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 24 2006
Added on Sep 26 2006
1 comment
62 views