Create List from Object Array - Java Collection Framework

Java examples for Collection Framework:List

Description

Create List from Object Array

Demo Code


import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
 
public class Main {
 
  public static void main(String[] args) {
    String[] strArray = new String[]{"Object","Array","Converted","To","List","java2s.com"};
   /*from  ww  w  .  ja  v  a2 s.com*/
    List list = Arrays.asList(strArray);
   
    Iterator itr = list.iterator();
   
    while(itr.hasNext()){
      System.out.println(itr.next());
    }
  }
}

Result


Related Tutorials