Skip to content

Instantly share code, notes, and snippets.

@developer-sdk
Created July 4, 2016 14:00
Show Gist options
  • Select an option

  • Save developer-sdk/46ffe804b08d7ef5c8d134b8e0f99630 to your computer and use it in GitHub Desktop.

Select an option

Save developer-sdk/46ffe804b08d7ef5c8d134b8e0f99630 to your computer and use it in GitHub Desktop.
Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract! 에러 수정
Arrays.sort(array, new Comparator<int[]>() {
@Override
public int compare(int[] a, int[] b) {
System.out.printf("%d %d\n", a[1], b[1]);
// 에러 구문
// return (a[1] < b[1]) ? -1 : 1;
// 수정 구문
return (a[1] <= b[1]) ? -1 : 1;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment