Saturday 9 May 2015

Convert Array to ArrayList


How to Convert Array to ArrayList In java:

We can make a arraylist from array using asList() method of array in java.

import java.util.ArrayList;
import java.util.Arrays;

public class ArrayToArrayList {

public static void main(String[] args) {
   
    String [] brr ={"HTML","PHP","JAVA","C"};

    ArrayList<String> arr= new ArrayList<String>(Arrays.asList(brr));

    System.out.println("ArrayList Is ="+arr);   

}   

}


Output:

ArrayList Is =[HTML, PHP, JAVA, C]



Related Posts: 

 


Storing Java Object In ArrayList



No comments:

Post a Comment