Developing Algorithms Using ArrayLists

AP Computer Science A· difficulty 4/5

To convert an ArrayList<Integer> to int[]:

  • A

    Loop and copy each element

    check_circle
  • B

    list.toIntArray()

  • C

    Cast to int[]

  • D

    list.toArray()

Explanation

Generic toArray returns Integer[]; need manual loop for int[].

Want 10 more like this — adaptive to your weak spots?

Related questions