Skip to content

Instantly share code, notes, and snippets.

Created Nov 7, 2021
What would you like to do?
Surprising Java behaviour...
import java.util.List;
import java.util.Arrays;
import java.util.Collections;
class Demo {
static class NotComparable {}
public static void main(String[] args) {
List<NotComparable> list = Arrays.asList(new NotComparable(), new NotComparable());
Collections.sort(list, null);
// Or the following, which is equivalent:
// list.sort(null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment