Skip to content

Commit a2f683e

Browse files
CapitalizeOnlyFirstLetter
2 parents 5417b62 + 4f233d5 commit a2f683e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

dist/1.x/string-utils-1.1.0.jar

103 Bytes
Binary file not shown.

src/main/java/wniemiec/util/java/StringUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public static <T> String implode(List<T> list, String delimiter) {
4444
response.append(delimiter);
4545
}
4646

47-
removeLastCharacter(response);
47+
if (!delimiter.isEmpty()) {
48+
removeLastCharacter(response);
49+
}
4850

4951
return response.toString();
5052
}

src/test/java/wniemiec/util/java/StringUtilsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ void testImplode() {
1414

1515
Assertions.assertEquals("hello world", obtained);
1616
}
17+
18+
@Test
19+
void testHelloWorldEmptyDelimiter() {
20+
List<String> items = List.of("hello", "world");
21+
String obtained = StringUtils.implode(items, "");
22+
23+
Assertions.assertEquals("helloworld", obtained);
24+
}
1725

1826
@Test
1927
void testImplodeWithNullList() {

0 commit comments

Comments
 (0)