Java examples for java.util:List Operation
merge Varargs of list
//package com.java2s; import java.util.*; public class Main { public static void main(String[] argv) { List many = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(merge(many)); }/*from w ww . ja v a 2 s .c om*/ public static <T> List<T> merge(List<T>... many) { ArrayList<T> ret = new ArrayList(); for (List<T> list : many) { if (list != null) { for (T val : list) { if (!ret.contains(val)) { ret.add(val); } } } } ret.trimToSize(); return ret; } public static <T> List<T> merge(T[]... many) { ArrayList<T> ret = new ArrayList(); for (T[] list : many) { if (list != null) { for (T val : list) { if (!ret.contains(val)) { ret.add(val); } } } } ret.trimToSize(); return ret; } }