//only works in java 8 or later
list.stream().mapToInt(i -> i).toArray();
int[] ints = {1,2,3};
List<Integer> list = Arrays.stream(ints).boxed().collect(Collectors.toList());
int[] arr = {1,2,3};
IntStream.of(arr).boxed().collect(Collectors.toList());
import java.util.*;
import java.util.stream.Collectors;
// java 8+
List<Integer> list = Arrays.stream(nums).boxed().collect(Collectors.toList());
// java 16+
List<Integer> list = Arrays.stream(nums).boxed().toList();
List<Integer> al = new ArrayList<Integer>();
Integer[] arr = new Integer[al.size()];
arr = al.toArray(arr);
int[] ints = {1, 2, 3};
List<Integer> intList = new ArrayList<Integer>(ints.length);
for (int i : ints)
{
intList.add(i);
}
int[] ints = {1, 2, 3};
List<Integer> intList = new ArrayList<Integer>(ints.length);
for (int i : ints)
{
intList.add(i);
}
templist.stream().mapToInt(i->i).toArray();
Your_ArrayList_Name.stream().mapToInt(k->k).toArray();