Array to List

In this chapter you will learn:

  1. Convert array to list

Convert array to list

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

The following code creates List from Object Array.

import java.util.Arrays;
import java.util.List;
//from  j ava2s.co  m
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:

Next chapter...

What you will learn in the next chapter:

  1. Convert array to set
Home » Java Tutorial » Array
Java Array
Create an Array
Array Index and length
Multidimensional Arrays
Array examples
Array copy
Array compare
Array Binary search
Array Search
Array sort
Array to List
Convert array to Set
Array fill value
Array to String
Array element reverse
Array element delete
Array shuffle
Array element append
Array min / max value
Sub array search
Get Sub array
Array dimension reflection
Array clone