Android examples for java.util:Collection Element
Append elements from src Collection to dest Collection.
//package com.book2s; import java.util.Collection; public class Main { public static void main(String[] argv) { Collection src = java.util.Arrays.asList("asdf", "book2s.com"); Collection dest = java.util.Arrays.asList("asdf", "book2s.com"); appendElements(src, dest);/*from ww w.j ava 2s . co m*/ } /** Append elements from src to dest. * * @param src - Collection containing data to be appended. * @param dest - Collection to have data appended to. */ public static <T> void appendElements(Collection<? extends T> src, Collection<? super T> dest) { copyElements(src, dest, false); } /** Copy elements from src to dest. * * @param src - Collection containing data to be copied. * @param dest - Collection to have the data copied to. * @param clearDestination - whether to clear all contents from destination prior to copying. */ public static <T> void copyElements(Collection<? extends T> src, Collection<? super T> dest, boolean clearDestination) { if (clearDestination) { dest.clear(); } for (T t : src) { dest.add(t); } } }