Java List Join join(List... ls)

Here you can find the source of join(List... ls)

Description

join

License

Apache License

Return

Joined version of the lists.

Declaration

public static <T> List<T> join(List<T>... ls) 

Method Source Code

//package com.java2s;
/**/*from  w ww . j  a  v  a 2  s . c  o  m*/
Copyright 2012 David Stark
    
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
    
   http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

import java.util.ArrayList;

import java.util.List;

import static java.util.Collections.*;

public class Main {
    /** @return Joined version of the lists. */
    public static <T> List<T> join(List<T>... ls) {
        int size = 0;
        for (List<T> l : ls) {
            size += l.size();
        }
        ArrayList<T> joint = new ArrayList<T>(size);
        for (List<T> l : ls) {
            joint.addAll(l);
        }
        return unmodifiableList(joint);
    }
}

Related

  1. join(List objs, String delim)
  2. join(List target, String splite)
  3. join(List tokens, String delimiter)
  4. join(List values, String separator)
  5. join(List... lists)
  6. join(List... elements)
  7. join(String _delimiter, List _strings)
  8. join(String delimiter, List strings)
  9. join(String joiner, List joinees)