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;
/*  j  av a2 s .  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. How to fill value to an array
  2. Fill an array of boolean value
Home » Java Tutorial » Data Types

Java Primitive Data Types
Java byte type
Java byte type conversion
Java short type
Java short type conversion
Java int type
Java int type conversion
Java long type
Java long type conversion
Java float type
Java float type conversion
Java double type
Java double type creation and comparison
Java double type conversion
Java Automatic Type Conversion and Casting
Data type casting
Java type promotion
Java char type
Java char conversion
Java char value and its attributes
Java boolean type
Java boolean type conversion
Autoboxing and auto-unboxing
Java Array
Create an Array
Array Index and length
Multidimensional Arrays
Array examples
Array copy
Array compare
Array Binary search
Array sort
Array to List
Array fill value
Array to String
BigInteger class
BigInteger creation
BigInteger add, subtract, multiply and divide
BigInteger power and modPow
BigInteger conversion
BigInteger to String
BigInteger bit and,or,xor,test,flip,negate
BigInteger bit shift left and right
BigInteger prime value
BigDecimal
BigDecimal constants
BigDecimal Rounding mode
BigDecimal creation
BigDecimal calculation
BigDecimal convert
BigDecimal Comparison
BigDecimal to String
BigDecimal decimal point
BigDecimal precision
BigDecimal format
Currency class