Skip to content

Instantly share code, notes, and snippets.

@entrofi
Created March 2, 2019 08:21
Show Gist options
  • Save entrofi/bf0483748c525058370575e7c8ef3332 to your computer and use it in GitHub Desktop.
Save entrofi/bf0483748c525058370575e7c8ef3332 to your computer and use it in GitHub Desktop.
Java 8 Method References
List<SomeComparableObject> objects = Arrays.asList( o1, o2, o3, ...);
ojbects.sort((SomeComparableObject o1, SomeComparableObject o2) -> o1.compareTo(o2)); // or with method reference
objects.sort(SomeComparableObject::compareTo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment