Java Utililty Methods List Create

List of utility methods to do List Create

Description

The list of methods to do List Create are organized into topic(s).

Method

StringcreateMultiParamMessage(String aPrefix, String aSuffix, List aParams)
create Multi Param Message
StringBuilder tLogTextBuilder = new StringBuilder();
tLogTextBuilder.append(aPrefix);
for (Object tCurrentParam : aParams) {
    tLogTextBuilder.append("\"");
    tLogTextBuilder.append(tCurrentParam.toString());
    tLogTextBuilder.append("\" ");
tLogTextBuilder.append(aSuffix);
...
StringcreateMultiSelectionValue(List values)
create Multi Selection Value
Collections.sort(values);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < values.size(); i++) {
    if (i > 0) {
        sb.append(' ');
    sb.append("\"" + values.get(i) + "\"");
return sb.toString();
ListcreateMutableList(Collection collection)
create Mutable List
List<E> mutableList = new ArrayList<>();
if (isNotEmpty(collection)) {
    for (E data : collection) {
        mutableList.add(data);
return mutableList;
ListcreateNewList(Class type)
create New List
if (type == List.class) {
    return new ArrayList();
} else if (type.isInterface()) {
    throw new RuntimeException("Can't instantiate a list type: " + type);
try {
    return (List) type.newInstance();
} catch (Exception e) {
...
voidcreateNormalDistributionByBootstrapping(List values1, List values2, final List sums1, final List sums2)
Creates normal distribution by bootstrapping the given samples.
if (values1.size() < 3 * NUM_ITEMS_IN_SUM || values2.size() < 3 * NUM_ITEMS_IN_SUM) {
    throw new RuntimeException(
            "Cannot conduct t-test on non normally distributed sample sets. Not enough data points!");
double sum = 0;
int counter = 0;
for (Number num : values1) {
    if (counter % NUM_ITEMS_IN_SUM == 0 && counter != 0) {
...
ListcreateNormativeTroopAllocation(List probs)
Creates a troop allocation where 100% of troops are allocated against the group or location with the highest probability.
if (probs != null && !probs.isEmpty()) {
    ArrayList<Integer> I = new ArrayList<Integer>(probs.size());
    int maxProb = Integer.MIN_VALUE;
    int maxProbIndex = 0;
    int i = 0;
    for (Integer prob : probs) {
        if (prob > maxProb) {
            maxProb = prob;
...
ListcreateNullElementList(int size)
create Null Element List
List lst = new ArrayList(size);
for (int i = lst.size(); i < size; i++) {
    lst.add(null);
return lst;
ListcreateNullList(int numberOfElements)
Create a List of the specified size filled with null, in order to be able to use set() to set elements in arbitrary order.
List<T> list = new ArrayList<T>(numberOfElements);
for (int j = 0; j < numberOfElements; j++) {
    list.add(null);
return list;
ArrayListCreateObjectList(Object... values)
Creates a list of objects from an array of objects.
ArrayList results = new ArrayList();
Collections.addAll(results, values);
return results;
ListcreateOneElementList(T element)
creates an array list with the one given element.
List<T> list = new ArrayList<T>();
list.add(element);
return list;