Skip to content

Commit ba286a2

Browse files
Update src/main/java/org/dsa/common/Utils.java
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 16e4b2e commit ba286a2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/dsa/common/Utils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ public class Utils {
1111
* @return the array elements separated by the delimiter; an empty string if the array has no elements
1212
*/
1313
public static String intArrToStr(int[] arr, String delimiter) {
14+
if (arr == null || delimiter == null) {
15+
throw new IllegalArgumentException("Array and delimiter must not be null");
16+
}
1417
return Arrays.stream(arr)
1518
.mapToObj(String::valueOf)
16-
.reduce((a, b) -> a + delimiter + b)
17-
.orElse("");
19+
- .reduce((a, b) -> a + delimiter + b)
20+
.collect(java.util.stream.Collectors.joining(delimiter));
1821
}
1922

2023
/**

0 commit comments

Comments
 (0)