Java List Create createDefaultValueList(int capacity, T defaultValue)

Here you can find the source of createDefaultValueList(int capacity, T defaultValue)

Description

creates a list containing the defaultValue as each entry.

License

Open Source License

Parameter

Parameter Description
T a parameter
capacity a parameter
defaultValue a parameter

Declaration

public final static <T> List<T> createDefaultValueList(int capacity, T defaultValue) 

Method Source Code


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

public class Main {
    /**/*from ww w. j  av a  2 s .c  om*/
     * creates a list containing the defaultValue as each entry.
     * 
     * @param <T>
     * @param capacity
     * @param defaultValue
     * @return
     */
    public final static <T> List<T> createDefaultValueList(int capacity, T defaultValue) {
        List<T> list = new ArrayList<T>(capacity);
        for (int i = 0; i < capacity; i++) {
            list.add(defaultValue);
        }
        return list;
    }
}

Related

  1. createConflictMessage(List conflicts)
  2. createConfusionMatrix(HashMap> tempM, List actualLabelsList, List predictedLabelsList)
  3. createConsultInfoMap(List resAry)
  4. createCSVLine(final char textQ, final char fieldD, final List values)
  5. createDefaultGroup(String name, String prefabGroup, List nodes)
  6. createDelimitedString(String rawListAsString)
  7. createDoubleList(double[] values)
  8. createDriverSheetNames(List driverBeans)
  9. createEmptyAdjacencyList(int n)

  10. HOME | Copyright © www.java2s.com 2016