I am trying to join int[] (array of int) using Google Guava’s Joiner class.
Example:
int[] array = { 1, 2, 3 };
String s = Joiner.on(", ").join(array); // not allowed
I checked StackOverflow and Google. There is no “one-liner” in foundation classes to convert int[] to Integer[] or List<Integer>. It always requires a for loop, or your own hand-rolled helper function.
Any advice?
Ints is a Guava library containing helper functions.
Given
int[] array = { 1, 2, 3 }you can use the following:Or more succinctly: