Created
November 7, 2021 13:23
-
-
Save nrinaudo/28ec925c033769056ce4397f4160fe68 to your computer and use it in GitHub Desktop.
Surprising Java behaviour...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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