Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#CompareTo' - 1 code snippet(s) found

 Sample 1. Bitwise comparison of objects , compareTo Implementation

public int compareTo(Object other) {
   Buffer right = ((Buffer) other);
   byte[] lb = this.get();
   byte[] rb = right.get();
   for (int i = 0; i < count && i < right.count; i++) {
      int a = (lb[i] & 0xff);
      int b = (rb[i] & 0xff);
      if (a != b) {
         return a - b;
      }
   }
   return count - right.count;
}

   Like      Feedback     compareTo  java.nio.Buffer



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner