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));


<source: adam bien>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s