HOW TO CONVERT AN ARRAY INTO AN ARRAYLISTS IN JAVA

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
Java 
 854  View(s)
Ratings:
Rate this:
How to convert an array into an arrayLists in java ?
  1. Mayank Tripathi

    Post:397

    Points:3117
    Re: How to convert an array into an arrayLists in java

    Suppose u have a string array :

    String[ ] names = {"Tom", "Tim", "Ben", "Jack", "Alisa", "Rose"};

    We don't exactly convert this array to arraylist , but we can view and use this array as array list ,

    List<String> nameList =  Arrays.asList (names);

    also if you want arraylist:

    ArrayList <String> nameList = new ArrayList<String> (Arrays.asList(names));

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!