ArrayList - converting string array to ArrayList

// ArrayList
// String array to ArrayList

/*
Write a java program to convert String array to ArrayList
*/

import java.util.*;

class SAtoAL
{
     public static void main(String as[])
     {
          // Creating a String array
          String[] SA = new String[]{"CSE", "IT","ECE","ECE"};
         
          // Converting string array to ArrayList
          ArrayList<String> al = new ArrayList<>(Arrays.asList(SA));
         
          System.out.println("Elements in ArrayList are : "+al);
     }
}

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu