Created
August 16, 2020 02:08
-
-
Save HomoEfficio/221baf76513e92ca8638933fe7f676e3 to your computer and use it in GitHub Desktop.
This file contains 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
Map.Entry<String, Long> mostCommonEntry = | |
List.of("나 혼자 길을 걷고", "나 혼자 티비 보고", "나 혼자 취해보고", "이렇게 매일 울고 불고") | |
.stream() | |
.map(s -> s.split(" ")) | |
.flatMap(Arrays::stream) | |
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting())) | |
.entrySet().stream() | |
.min(Map.Entry.comparingByValue(Comparator.reverseOrder())) | |
.orElseThrow(() -> new RuntimeException("no entry error")); | |
System.out.println(mostCommonEntry.getKey() + ": " + mostCommonEntry.getValue()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment