Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014, 2015 Red Hat. All rights reserved. This program and the accompanying
 * materials are made available under the terms of the Eclipse Public License v1.0 which accompanies
 * this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: Red Hat - Initial Contribution
 *******************************************************************************/

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**
     * Joins all given elements in a single (flat) List.
     * 
     * @param element first element to include in the list
     * @param otherElements other elements to include in the list
     * @param <T> the elements type
     * @return a list combining all given elements
     */
    public static <T> List<T> join(T element, List<T> otherElements) {
        final List<T> result = new ArrayList<>();
        result.add(element);
        result.addAll(otherElements);
        return result;
    }
}