We need to write a java program to convert a java list to an array.

To achieve this we will follow the following standard approach.

Steps to Convert Java List to Array

  1. Declare and add items to the List.
  2. Declare an integer array of size equal to the number of items in the List.
  3. Itereate through List using for Loop.
  4. Initialize the array with list item inside the loop.

Java List to Array

Output

In the above program, we have used integer array because the list item is an integer. The array type should be the same as the type of data/object in the list.

If you have any suggestion then comment below.

Leave a Reply

Close Menu