Here you can find the source of createNullList(int numberOfElements)
Parameter | Description |
---|---|
numberOfElements | a parameter |
public static <T> List<T> createNullList(int numberOfElements)
//package com.java2s; /******************************************************************************* * This file is part of Tmetrics.//from w ww . j a v a 2 s . c o m * * Tmetrics is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Tmetrics is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Tmetrics. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { /** * Create a List of the specified size filled with null, in order to be able * to use set() to set elements in arbitrary order. * * @param numberOfElements * @return */ public static <T> List<T> createNullList(int numberOfElements) { List<T> list = new ArrayList<T>(numberOfElements); for (int j = 0; j < numberOfElements; j++) { list.add(null); } return list; } }