Java List Copy copy(List master)

Here you can find the source of copy(List master)

Description

copy

License

Open Source License

Declaration

public static <E> List<E> copy(List<E> master) 

Method Source Code

//package com.java2s;
/**//from ww w.  ja  va2  s.  c  o m
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static <E> List<E> copy(List<E> master) {
        if (master == null) {
            return null;
        }

        return new ArrayList<E>(master);
    }

    public static <E> void copy(List<E> master, List<? super E> copy) {
        if ((master == null) || (copy == null)) {
            return;
        }

        copy.clear();

        copy.addAll(master);
    }
}

Related

  1. copy(java.util.List list)
  2. copy(List master)
  3. copy(List oldlist)
  4. copy(List src, boolean immutable)
  5. copy(List src, int offset, int length)
  6. copy(List source, int index)
  7. copy(List list)
  8. copy(List list)
  9. copy(List list)