Android examples for java.util:Collection Element
Copy 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"); boolean clearDestination = true; copyElements(src, dest, clearDestination); }/*from w w w . j a v a2s .c o m*/ /** 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); } } }