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


Notice: compact(): Undefined variable: limits in /home/javaprof/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/javaprof/public_html/wp-includes/class-wp-comment-query.php on line 853

Leave a Reply

Your email address will not be published. Required fields are marked *

72 − 64 =