Skip to content

Instantly share code, notes, and snippets.

Created Mar 31, 2013
What would you like to do?
Ad-hoc queries over collections (LINQ in Java)
// Print the names of albums that have at least one track rated four or higher, sorted by name.
.filter(a -> -> (t.rating >= 4)))
.sorted(comparing((Album album) ->
.forEach(album -> System.out.println(;
// Merge tracks from all albums
List<Track> allTracks =
.flatMap((Album album) ->
// Group album tracks by rating
Map<Integer, List<Track>> tracksByRating =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment