Here you can find the source of truncateList(final List
Parameter | Description |
---|---|
full | the full ist to truncate |
maxSize | the maximum size of the returned view |
public static <E> List<E> truncateList(final List<E> full, int maxSize)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**/*w ww .j a va2 s . c o m*/ * Truncates the given list to have the given maximum size. * @param full the full ist to truncate * @param maxSize the maximum size of the returned view * @return a view of the full list as with {@link List#subList(int, int)}. */ public static <E> List<E> truncateList(final List<E> full, int maxSize) { final int numToDisplay = Math.min(full.size(), maxSize); return full.subList(0, numToDisplay); } }