Java. List to int[] and backwards

example

int[] example1 = list.stream().mapToInt(i->i).toArray();
// OR
int[] example2 = list.stream().mapToInt(Integer::intValue).toArray();

int [] ints = list.stream().mapToInt(Integer::intValue).toArray();

backwards

int[] intArray = {1, 2, 3, 4};
Integer[] integerArray = Arrays.stream(intArray)
                               .boxed()
                               .toArray(Integer[]::new);
This entry was posted in Без рубрики. Bookmark the permalink.

Leave a Reply

Your email address will not be published.