Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

public class Main {
    public static <T> List<T> subList(List<T> list, int first, int end) {
        if (null == list || list.isEmpty())
            return null;
        int size = list.size();
        int fromIndex = first;
        int toIndex = end;
        if (fromIndex < 0) {
            toIndex = 0;
        }
        if (toIndex > size) {
            toIndex = size;
        }
        if (fromIndex > toIndex)
            return null;
        return list.subList(fromIndex, toIndex);
    }
}