Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//     The contents of this file are subject to the Mozilla Public License

import java.util.*;

public class Main {
    /**
     * Provides a wrapper to create a list out of a collection
     * @param wrappedCollection nullable collection
     * @param <T> type parameter of collection and resulting list
     * @return list of Ts from wrappedCollection or empty list
     */
    public static <T> List<T> listFrom(Collection<T> wrappedCollection) {
        if (wrappedCollection == null || wrappedCollection.isEmpty()) {
            return new ArrayList<T>();
        } else {
            return new ArrayList<T>(wrappedCollection);
        }
    }
}