/** *Teststhejoin()methodsonString
*/ publicvoid testJoinStringVarargs() { // check a non-null join of String array (var-args) elements
String expectedResult = BEGIN + DASH + JIM + DASH + JOHN + DASH + AND_JOE;
String result = String.join(DASH, BEGIN, JIM, JOHN, AND_JOE);
assertEquals(result, expectedResult, "BEGIN.join(DASH, JIM, JOHN, AND_JOE)"); // test with just one element
assertEquals(String.join(DASH, BEGIN), BEGIN);
}
publicvoid testJoinStringArray() { // check a non-null join of Object[] with String elements
String[] theBs = {BILL, BOB, AND_BO};
String result = String.join(DASH, theBs);
String expectedResult = BILL + DASH + BOB + DASH + AND_BO;
assertEquals(result, expectedResult, "String.join(DASH, theBs)");
}
publicvoid testJoinEmptyStringArray() { // check a non-null join of Object[] with String elements
String[] empties = {};
String result = String.join(DASH, empties);
assertEquals(result, "", "String.join(DASH, empties)");
}
@Test(expectedExceptions = {NullPointerException.class}) publicvoid testJoinNullStringArray() { // check a non-null join of Object[] with String elements
String[] empties = null;
String result = String.join(DASH, empties);
}
@Test(expectedExceptions = {NullPointerException.class}) publicvoid testJoinNullIterableStringList() { // check join of an Iterables
List<CharSequence> theZsList = null;
String.join(DASH, theZsList);
}
publicvoid testIgnoreDelimiterCoderJoin() { // 8267529: Ensure that joining zero or one latin-1 Strings with a UTF-16 // delimiter produce a String with a latin-1 coder, since the delimiter // is not added.
assertEquals("", new StringJoiner("\u2013").toString());
assertEquals("foo", new StringJoiner("\u2013").add("foo").toString());
assertEquals("", String.join("\u2013"));
assertEquals("foo", String.join("\u2013", "foo"));
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.