Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static <E> List<E> limitResults(List<E> list, int maxIndex) {
        if (maxIndex < 0) {
            throw new IllegalArgumentException("Expected non negative max index, received " + maxIndex); //$NON-NLS-1$
        }
        if (maxIndex > 0 && maxIndex <= list.size()) {
            return list.subList(0, maxIndex);
        }
        return list;
    }
}