Here you can find the source of toList(String[] array)
public static final List<String> toList(String[] array)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static final List<String> toList(String[] array) { return let(array, null); }// w w w . ja v a 2s . co m @SuppressWarnings("unchecked") public static final <T extends Collection<String>> T let(String[] array, Class<T> tClazz) { T result = null; if (null == tClazz) { result = (T) new ArrayList<String>(); } else { try { result = tClazz.newInstance(); } catch (Exception e) { e.printStackTrace(); } } if (null != array && array.length > 0) { for (String e : array) { result.add(e); } } return result; } }