Java Collection Copy shallowCopy(Collection collection)

Here you can find the source of shallowCopy(Collection collection)

Description

shallow Copy

License

Apache License

Declaration

public static <T> Collection<T> shallowCopy(Collection<T> collection) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

import java.util.ArrayList;

public class Main {
    public static <T> Collection<T> shallowCopy(Collection<T> collection) {
        ArrayList<T> copied = new ArrayList<T>(collection.size());
        for (T element : collection) {
            copied.add(element);/*from ww  w  .j ava2  s .co  m*/
        }
        return copied;
    }
}

Related

  1. copyRemainder(final T[] sourceArray, final int startIndex, final Collection collector)
  2. copyStringCollection(Collection strings)
  3. copyWithoutNull(Collection orig)
  4. createSet(Collection toCopy)
  5. maskedCopyOf(final Collection source, final Collection mask)
  6. toUnmodifiableCopy(Collection collection)