Convert array to list

ReturnMethodSummary
static<T> List<T>asList(T... a)Returns a fixed-size list backed by the specified array.

Create List from Object Array


import java.util.Arrays;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    String[] strArray = new String[] { "java2s.com", "A", "B", "C", "D" };
    List list = Arrays.asList(strArray);
    System.out.println(list);

  }
}

The output:


[java2s.com, A, B, C, D]
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.