I am using the following way but I got an error
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(5);
int[] arr = list.toArray();
}
The error I got is
java: incompatible types: java.lang.Object[] cannot be converted to int[]