Java List Copy copyListOnlySpecified(List list, int[] indexes)

Here you can find the source of copyListOnlySpecified(List list, int[] indexes)

Description

copy List Only Specified

License

Creative Commons License

Declaration

public static <T> List<T> copyListOnlySpecified(List<T> list, int[] indexes) 

Method Source Code

//package com.java2s;
/*//from w  ww.  j  a  va  2s  .  c  o  m
 * Copyright (C) 2013 Maino
 * 
 * This work is licensed under the Creative Commons
 * Attribution-NonCommercial-NoDerivs 3.0 Unported License. To view a copy of
 * this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send
 * a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco,
 * California, 94105, USA.
 * 
 */

import java.util.*;

public class Main {
    public static <T> List<T> copyListOnlySpecified(List<T> list, int[] indexes) {
        List<T> newlist = new ArrayList<T>();
        for (int i = 0; i < list.size(); i++) {
            if (Arrays.asList(indexes).contains(i)) {
                newlist.add(list.get(i));
            }
        }
        return newlist;
    }
}

Related

  1. copyList(List list)
  2. copyList(List list)
  3. copyList(List master, List slave)
  4. copyList(List original)
  5. copyList(Object object)
  6. copyListRaw(List master, List slave)
  7. copyNullable(List original)
  8. copyNullSafeMutableList(Collection list)
  9. copyObjectList(List objects)

    HOME | Copyright © www.java2s.com 2016