Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to convert string Stream to join them in Java?
Let us create string Stream:
Streamstream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming");
Convert the above string stream and join them with Collectors:
final String str = stream.collect(Collectors.joining(" "));
The following is an example to convert string Stream to join them:
Example
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Demo {
public static void main(String[] args) {
Stream stream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming");
final String str = stream.collect(Collectors.joining(" "));
System.out.println("Join result...\n"+str);
}
}
Output
Join result... Bing Bang Theory Vampire Diaries Game of Thrones Homecoming
Advertisements
