How can I convert int[]
to comma-separated String in Java?
int[] intArray = {234, 808, 342};
Result I want:
\"
You want to convert the ints to strings, and join them with commas. You can do this with streams.
int[] intArray = {234, 808, 342};
String s = Arrays.stream(intArray)
.mapToObj(String::valueOf) // convert each int to a string
.collect(Collectors.joining(", ")); // join them with ", "
Result:
"234, 808, 342"