Convert Array to List - Android java.lang

Android examples for java.lang:array convert

Description

Convert Array to List

Demo Code

import java.util.ArrayList;
import java.util.List;

public class Main {

  public static <M extends Object> List<M> toList(M[] array) {
    if (array == null)
      return new ArrayList<>();

    List<M> result = new ArrayList<>(array.length);
    for (M m : array)
      result.add(m);/* ww  w .j  a va  2 s. co m*/
    return result;
  }

}

Related Tutorials