Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import java.util.Collection;

import java.util.stream.Stream;

public class Main {
    /**
     * Returns the given collection as stream.
     *
     * @param <T>
     *            the generic type
     * @param source
     *            the source
     * @param parallel
     *            <code>true</code> if the stream should be a parallel stream
     * @return the stream
     */
    public static <T> Stream<T> asStream(Collection<T> source, boolean parallel) {
        return parallel ? source.parallelStream() : source.stream();
    }
}