Skip to content

Instantly share code, notes, and snippets.

@stefanesterer
Last active December 9, 2020 11:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save stefanesterer/a274b23cf5554343fb72cdea0233f2b2 to your computer and use it in GitHub Desktop.
Java 15 Features
List<Merchant> findTopMerchants(List<Merchant> merchants, int month) {
// Local record
record MerchantSales(Merchant merchant, double sales) {}
return merchants.stream()
.map(merchant -> new MerchantSales(merchant, computeSales(merchant, month)))
.sorted((m1, m2) -> Double.compare(m2.sales(), m1.sales()))
.map(MerchantSales::merchant)
.collect(toList());
}
String html = "<html>\n" +
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>\n";
record Point(int x, int y) { }
String html = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment