Collections

How to add int array to arraylist in java

package com.candidjava;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class ArrayListAddIntArray {
  public static void main(String[] args) {
    Integer[] num = { 12, 33, 44, 55, 66, 77 };
    // Using Arrays.aslist
    List l = new ArrayList<Integer>(Arrays.asList(num));
    System.out.println("adding using arrays.aslist:");
    System.out.println(l);
    //Using Collections.addall
    List l1=new ArrayList<Integer>();
    Collections.addAll(l1,num);
    System.out.println("adding using collections.addall:");
    System.out.println(l1);
    //
    int[] n=new int[]{22,33,44,55};
    List<int[]> l2 = new ArrayList<>();
    l2.add(n);
    System.out.println(l2.get(0)[0]);
    System.out.println(l2.get(0)[1]);
    System.out.println(l2.get(0)[2]);
    System.out.println(l2.get(0)[3]);
  }
}

OUTPUT

adding using arrays.aslist:
[12, 33, 44, 55, 66, 77]
adding using collections.addall:
[12, 33, 44, 55, 66, 77]
22
33
44
55