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

ListasList(T... a)
as List
if (a == null || a.length == 0) {
    return new ArrayList<T>();
return Arrays.asList(a);
ListasList(T... array)
as List
if (array == null) {
    return null;
List<T> list = new ArrayList<T>(array.length);
for (T t : array) {
    list.add(t);
return list;
...
ListasList(T... elements)
as List
List<T> toReturn = new ArrayList<>();
toReturn.addAll(Arrays.asList(elements));
return toReturn;
ListasList(T... items)
as List
return Arrays.asList(items);
ListasList(T... objs)
Return list literals as list and return array as list; also handle null array.
return objs != null ? Arrays.asList(objs) : new ArrayList<T>();
ListasList(T[] array)
as List
List<T> list = new ArrayList<>();
for (T value : array) {
    list.add(value);
return list;
ListasListBox(double[] a)
as List Box
List<Double> list = new ArrayList<Double>();
for (int i = 0; i < a.length; i++)
    list.add(a[i]);
return list;
ListasListNoNulls(T... array)
as List No Nulls
ArrayList<T> result = new ArrayList<T>();
for (T t : array) {
    if (t != null) {
        result.add(t);
return result;
List>create2DHorizontalIndexList(final int n)
create D Horizontal Index List
List<List<Integer>> result = new ArrayList<List<Integer>>();
result.add(new ArrayList<Integer>());
for (int i = 0; i < n; i++) {
    result.get(0).add(i);
return result;
ArrayListcreateActMask(ArrayList stateActions, ArrayList beliefActions)
create Act Mask
ArrayList<Double> mask = new ArrayList<>(beliefActions.size());
for (int i = 0; i < beliefActions.size(); i++) {
    mask.add(0.0);
    int[] action = beliefActions.get(i);
    for (int[] act : stateActions) {
        if (Arrays.equals(act, action)) {
            mask.set(i, 1.0);
            break;
...