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

ListcreateListFromList(Collection collection)
create List From List
List<T> newList = new ArrayList<T>();
if (collection != null) {
    newList.addAll(collection);
return newList;
ListcreateListOfObjects(T... elements)
create List Of Objects
ArrayList<T> list = new ArrayList<T>(elements.length);
for (T element : elements) {
    list.add(element);
return list;
ListcreateListOfOneItem(Object item)
create List Of One Item
List list = new ArrayList();
list.add(item);
return list;
ListcreateListOfValidNumberOfPoints(int[] terms, int min, int max)
create List Of Valid Number Of Points
List<Integer> list = new ArrayList<Integer>();
createListOfValidNumberOfPoints(list, 0, terms, min, max);
Collections.sort(list);
return list;
ListcreateListWithArray(Object[] array)
Create a new array list with input array.
final ArrayList<Object> result = new ArrayList<Object>();
if (array == null) {
    return result;
for (Object obj : array) {
    result.add(obj);
return result;
...
ArrayListcreateListWithObjects(Object... objects)
create List With Objects
ArrayList<Object> list = new ArrayList<Object>();
list.addAll(Arrays.asList(objects));
return list;
HashMapcreateMapFromList(List list)
Simple List to HashMap creator
HashMap hmap = new HashMap(list.size());
Iterator iter = list.iterator();
while (iter.hasNext()) {
    Object oTemp = iter.next();
    hmap.put(oTemp, oTemp);
return hmap;
MapcreateMapOfObjects(List keys, List values)
create Map Of Objects
HashMap<K, V> map = new HashMap<K, V>(keys.size());
if (keys.size() == values.size()) {
    Iterator<K> keysIterator = keys.iterator();
    Iterator<V> valuesIterator = values.iterator();
    while (keysIterator.hasNext() && valuesIterator.hasNext()) {
        K key = keysIterator.next();
        V value = valuesIterator.next();
        map.put(key, value);
...
int[][]createMatrix(List source, List target)
Create matrix for the compare algorithms.
int M = source.size();
int N = target.size();
int[][] result = new int[M + 1][N + 1];
for (int i = M - 1; i >= 0; i--) {
    for (int j = N - 1; j >= 0; j--) {
        if (source.get(i).equals(target.get(j))) {
            result[i][j] = result[i + 1][j + 1] + 1;
        } else {
...
StringcreateMergedRegex(List regexes)
create Merged Regex
if (regexes == null) {
    return null;
StringBuilder mergedRegexStringBuilder = new StringBuilder("");
int regexCount = regexes.size();
mergedRegexStringBuilder.append("(");
for (int i = 0; i < regexCount; i++) {
    if ((i + 1) < regexCount) {
...