Here you can find the source of join(T element, List
Parameter | Description |
---|---|
element | first element to include in the list |
otherElements | other elements to include in the list |
T | the elements type |
public static <T> List<T> join(T element, List<T> otherElements)
//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 { /**//from w w w . j a v a2 s .c o m * 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; } }