Search in sources :

Example 21 with StringJoiner

use of java8.util.StringJoiner in project streamsupport by stefan-zobel.

the class StringJoinerTest method noAddAndEmptyValue.

public void noAddAndEmptyValue() {
    StringJoiner sj = new StringJoiner(DASH, "", "").setEmptyValue(EMPTY);
    assertEquals(sj.toString(), EMPTY);
    sj = new StringJoiner(DASH, "<..", "");
    assertEquals(sj.toString(), "<..");
    sj = new StringJoiner(DASH, "<..", "");
    assertEquals(sj.toString(), "<..");
    sj = new StringJoiner(DASH, "", "==>");
    assertEquals(sj.toString(), "==>");
    sj = new StringJoiner(DASH, "{", "}");
    assertEquals(sj.toString(), "{}");
}
Also used : StringJoiner(java8.util.StringJoiner)

Example 22 with StringJoiner

use of java8.util.StringJoiner in project streamsupport by stefan-zobel.

the class SortingNearlySortedPrimitive method arrayToString.

String arrayToString(int[] a) {
    int[] l = Arrays.copyOfRange(a, 0, WIDTH + 2);
    int[] r = Arrays.copyOfRange(a, a.length - (WIDTH + 2), a.length);
    StringJoiner sj = new StringJoiner(",", "[", "]");
    for (int i : l) {
        sj.add(Integer.toString(i));
    }
    sj.add("...");
    for (int i : r) {
        sj.add(Integer.toString(i));
    }
    return sj.toString();
}
Also used : StringJoiner(java8.util.StringJoiner)

Aggregations

StringJoiner (java8.util.StringJoiner)22 ArrayList (java.util.ArrayList)3 Test (org.testng.annotations.Test)2