Generic method to convert array to List - Java java.util

Java examples for java.util:List Convert

Description

Generic method to convert array to List

Demo Code


//package com.java2s;
import java.util.ArrayList;

public class Main {
    public static <T> ArrayList<T> arrayListOf(T... objects) {
        final ArrayList<T> list = new ArrayList<T>();
        for (T object : objects) {
            list.add(object);//from  w w  w  .  ja  va 2s.co  m
        }
        return list;
    }
}

Related Tutorials