Skip to content

Commit

Permalink
기본이 중요하다 [JavaVersion8]
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Diger committed Mar 21, 2024
1 parent 93e9afb commit cbd3e91
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions _posts/2024-03-16-JavaVersioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,23 @@ public static void main(String[] args) {
```java
public static void main(String[] args) {
// map()
List<String> words = Arrays.asList("Java", "Stream", "Map");
List<String> upperWords = words.stream()
.map(String::toUpperCase)
List<List<String>> mapList = Arrays.asList(
Arrays.asList("Java", "is"),
Arrays.asList("super", "fun")
);

List<Stream<String>> mapListStreamMap = mapList.stream()
.map(List::stream)
.collect(Collectors.toList());
System.out.println(upperWords);
// 결과 : [JAVA, STREAM, MAP]
System.out.println(mapListStreamMap);
// 결과 : [java.util.stream.ReferencePipeline$Head@378bf509, java.util.stream.ReferencePipeline$Head@5fd0d5ae]

// flatMap()
List<List<String>> listOfLists = Arrays.asList(
Arrays.asList("Java", "is"),
Arrays.asList("super", "fun")
);

List<String> flatList = listOfLists.stream()
.flatMap(List::stream)
.collect(Collectors.toList());
Expand Down

0 comments on commit cbd3e91

Please sign in to comment.