Created
May 8, 2022 08:57
-
-
Save bxb100/3efa4a7676455670d58a0e3dc4415ac4 to your computer and use it in GitHub Desktop.
Best way to join the String
This file contains hidden or 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
import java.util.StringJoiner; | |
import java.util.stream.Stream; | |
public class StringDemo { | |
public static void main(String[] args) { | |
StringJoiner sj = new StringJoiner(",", "[", "]"); | |
Stream.of("1", "2", "3").forEach(sj::add); | |
System.out.println(sj.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
since Java 1.8