Java tutorial
//package com.java2s; import java.util.*; public class Main { /** * Converts the specified Array to a Collection containing the same elements. * * @param source Array of Objects to be converted to a Collection. * @return Collection of Objects containing the elements of the specified Array. */ public static <E> Collection<E> toCollection(E[] source) { Collection<E> collection = null; if (source != null) { collection = new ArrayList<E>(); for (E next : source) { if (next != null) { collection.add(next); } } } return collection; } }