0
public int compareTo(Object o) {
   int search = ((AlbumModel)o).getSearchResult();
   if (search-this.searchResult==0) {
       return ((AlbumModel)o).dateModified-this.dateModified;
   } else {
       return search-this.searchResult;
   }
}

I use this code on JDK6 and it works perfectly. But when I try to use the code on JDK 7(++), it throws an Illegal argument exception.

khelwood
  • 55,782
  • 14
  • 81
  • 108
Yonatan
  • 150
  • 1
  • 9
  • What is the return type of ```dateModified```? is that ```int```? Can you paste the ```stackTrace()```? – papaya Dec 25 '19 at 08:12
  • yea it is int . – Yonatan Dec 25 '19 at 09:44
  • 1
    Does this answer your question? [Comparison method violates its general contract! Java 7 only](https://stackoverflow.com/questions/7849539/comparison-method-violates-its-general-contract-java-7-only) – user7217806 Dec 25 '19 at 16:53

0 Answers0