Java List Join joinLists( final List> lists)

Here you can find the source of joinLists( final List> lists)

Description

Joins the items of multiple lists into one list.

License

Open Source License

Declaration

public static <GPItem> List<GPItem> joinLists(
        final List<List<GPItem>> lists) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*ww  w . j  a v a2 s . c  o m*/
     * Joins the items of multiple lists into one list.
     * 
     * @return
     */
    public static <GPItem> List<GPItem> joinLists(
            final List<List<GPItem>> lists) {
        if (lists.size() == 0) {
            return new ArrayList<GPItem>(0);
        }
        final List<GPItem> joined = new ArrayList<GPItem>(lists.size()
                * lists.get(0).size());
        for (final List<GPItem> list : lists) {
            joined.addAll(list);
        }

        return joined;
    }
}

Related

  1. joinList(List items)
  2. joinList(List list, String glue)
  3. joinList(List list, String separator)
  4. joinList(List parts, String sep)
  5. joinList(String separater, List list)
  6. joinLists(List A, List B, double epsilon)
  7. joinLists(List... list)
  8. joinListToString(List lsStr, String sSeparator)
  9. joinLong(List lst, String prefix)