Java 8: Introducing StringJoiner

import java.util.StringJoiner;
import static;
import static org.junit.Assert.assertThat;
import org.junit.Test;

public class StringJoinerTest {

    public void join() {
        String expected = "duke,java";
        StringJoiner sj = new StringJoiner(",");
        String actual = sj.toString();
        assertThat(actual, is(expected));

    public void shortCut() {
        String expected = "duke,java";
        String actual = String.join(",", "duke", "java");
        assertThat(actual, is(expected));


Thanks to @gschmidl for the idea:

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you:!

NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: and newsletter:

A book about rethinking Java EE Patterns


Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments