We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 16e4b2e commit ba286a2Copy full SHA for ba286a2
src/main/java/org/dsa/common/Utils.java
@@ -11,10 +11,13 @@ public class Utils {
11
* @return the array elements separated by the delimiter; an empty string if the array has no elements
12
*/
13
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
+ }
17
return Arrays.stream(arr)
18
.mapToObj(String::valueOf)
- .reduce((a, b) -> a + delimiter + b)
- .orElse("");
19
+- .reduce((a, b) -> a + delimiter + b)
20
+ .collect(java.util.stream.Collectors.joining(delimiter));
21
}
22
23
/**
0 commit comments