All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wf.utils.java.data.list.ListUtils Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
package wf.utils.java.data.list;

import java.util.ArrayList;
import java.util.List;

public class ListUtils {

    public static  List copyOfRange(List list, int from, int to) {
        if (from < 0 || from >= list.size() || to < 0 || to >= list.size() || from > to)
            throw new IllegalArgumentException("Illegal extraction bounds");

        List result = new ArrayList<>(to - from + 1);

        for (int i = from; i <= to; i++)
            result.add(list.get(i));

        return result;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy