arraylist object 5b 5d toarray 28 29 method in java

Solutions on MaxInterview for arraylist object 5b 5d toarray 28 29 method in java by the best coders in the world

showing results for - "arraylist object 5b 5d toarray 28 29 method in java"
Nour
08 Oct 2020
1import java.util.ArrayList;
2import java.util.List;
3public class ArrayListObjectToArrayMethodExample
4{
5   public static void main(String[] args)
6   {
7      List<Integer> al = new ArrayList<Integer>();
8      al.add(12);
9      al.add(14);
10      al.add(16);
11      al.add(18);
12      al.add(20);
13      Object[] obj = al.toArray();
14      for(Object num : obj)
15      {
16         System.out.print(num + " ");
17      }
18   }
19}