Java examples for java.util:List Operation
Merge list to a single List
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static void main(String[] argv) { List lists = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(listCat(lists)); }//from w w w.j ava 2 s . c o m @SafeVarargs public static <A> List<A> listCat(List<A>... lists) { if (lists.length == 0) return Collections.<A> emptyList(); else if (lists.length == 1) return lists[0]; else { List<A> full = new ArrayList<A>(); for (List<A> xs : lists) full.addAll(xs); return full; } } }