SHARE
TWEET

Untitled

a guest Oct 18th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package books;
  2.  
  3. import java.util.Comparator;
  4.  
  5. public class BookComparator implements Comparator<Book> {
  6.  
  7.     @Override
  8.     public int compare(Book left, Book right) {
  9.         if (left.getTitle().compareTo(right.getTitle()) == 0) {
  10.             return left.getYear().compareTo(right.getYear());
  11.         }
  12.         return left.getTitle().compareTo(right.getTitle());
  13.     }
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top