I need to convert:
ArrayList<Double> list = new ArrayList<Double>(); in int[] arr;
Thank you in advance!
You can do, for example, like this:
List<Double> list = new ArrayList<>(); Double[] array = list.toArray(new Double[list.size()]); If you want to convert int[] arr to int[] arr then you can go like this:
int[] arr = new int[array.length]; for (int i = 0; i < array.length; i++) { arr[i] = (int) array[i]; } ArrayList<Double> list = new ArrayList<Double>(); int[] ints = list.stream().mapToInt(i -> i.intValue()).toArray(); Only consider that floating-point numbers will throw out an exception.
Source: https://ru.stackoverflow.com/questions/619825/
All Articles
list.toArray(...). - post_zeew