Java List Create createNullList(int numberOfElements)

Here you can find the source of createNullList(int numberOfElements)

Description

Create a List of the specified size filled with null, in order to be able to use set() to set elements in arbitrary order.

License

Open Source License

Parameter

Parameter Description
numberOfElements a parameter

Declaration

public static <T> List<T> createNullList(int numberOfElements) 

Method Source Code

//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;

    }
}

Related

  1. createMutableList(Collection collection)
  2. createNewList(Class type)
  3. createNormalDistributionByBootstrapping( List values1, List values2, final List sums1, final List sums2)
  4. createNormativeTroopAllocation( List probs)
  5. createNullElementList(int size)
  6. CreateObjectList(Object... values)
  7. createOneElementList(T element)
  8. createOrderedQuery(String attributeName, List ids)
  9. createOrgAttributeList()