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