Skip to content

Commit 64f6968

Browse files
committed
Add SplitSentenceToWord class to split sentences into words using streams
1 parent 0158d7f commit 64f6968

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.java8;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
public class SplitSentenceToWord {
7+
public static void main(String[] args) {
8+
List<String> sentenceList = Arrays.asList("Java World", "Rohit Sharma", "LTIMindtree explore world");
9+
List<String> stringList = sentenceList.stream()
10+
.flatMap(x -> Arrays.stream(x.split(" "))).toList();
11+
System.out.println(stringList);
12+
}
13+
}

0 commit comments

Comments
 (0)