Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;
import java.util.List;

public class Main {
    /**
     * Returns a truncated version of the specified <code>List</code>.
     * @param list the <code>List</code>
     * @param len the truncate length
     * @return the truncated <code>List</code>
     */
    public static List truncateList(List list, int len) {
        if (len >= list.size())
            return list;
        ArrayList newList = new ArrayList(len);
        for (int ii = 0; ii < len; ii++) {
            newList.add(list.get(ii));
        }
        return newList;
    }
}