Java examples for java.util:List Operation
Fills a List with null by calling #fillList(List,int,Object) with a null object.
//package com.java2s; import java.util.List; public class Main { public static void main(String[] argv) { List list = java.util.Arrays.asList("asdf", "java2s.com"); int size = 42; fillList(list, size);//w ww . ja v a 2s. c o m } /** * Fills a <code>List</code> with <code>null</code> * by calling {@link #fillList(List, int, Object)} * with a <code>null</code> object. * @param list the <code>List</code> that should be filled * @param size the resulting size of the <code>List</code> */ public static void fillList(List list, int size) { fillList(list, size, null); } /** * Fills a <code>List</code> with with the specified object * until it has the specified size. If the specified size is * equal or lower the <code>List</code> size, nothing happens. * @param list the <code>List</code> that should be filled * @param size the resulting size of the <code>List</code> */ public static void fillList(List list, int size, Object object) { for (int ii = list.size(); ii < size; ii++) { list.add(object); } } }