This code works (taken in the Javadoc):
List numbers = Arrays.asList(1, 2, 3, 4);
String commaSeparatedNumbers = numbers.stream()
.map(i -
Arrays.stream(int[]) creates an IntStream, not a Stream. So you need to call mapToObj instead of just map, when mapping an int to an object.
This should work as expected:
String commaSeparatedNumbers = Arrays.stream(numbers)
.mapToObj(i -> ((Integer) i).toString()) //i is an int, not an Integer
.collect(Collectors.joining(", "));
which you can also write:
String commaSeparatedNumbers = Arrays.stream(numbers)
.mapToObj(Integer::toString)
.collect(Collectors.joining(", "));