public class App {
public static void main(String[] args) {
List<Integer> list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9));
int[] arr = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
arr[i] = list.get(i);
}
System.out.println(Arrays.toString(arr)); // [1, 2, 3, 4, 5, 6, 7, 8, 9]
}
}
List<Integer> list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9));
Integer[] arr = list.toArray(new Integer[0]);
nt[] arr = list.stream().mapToInt(i -> i).toArray();
int[] arr = ArrayUtils.toPrimitive(list.toArray(new Integer[0]));
int[] arr = Ints.toArray(list);