Here you can find the source of slice(List
public static <T> List<T> slice(List<T> list, int start, int end)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012-2015 Codenvy, S.A. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w w w .j a v a 2s . c o m * Codenvy, S.A. - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<T> slice(List<T> list, int start, int end) { List<T> sliced = new ArrayList<>(); for (int i = start; i < end && i < list.size(); i++) { sliced.add(list.get(i)); } return sliced; } }