Here you can find the source of copyListOnlySpecified(List
public static <T> List<T> copyListOnlySpecified(List<T> list, int[] indexes)
//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; } }