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

ArrayListcreateIntListToN(int n)
createIntListToN: creates an ArrayList of n integers from 0 to n-1 useful to create a list for considering all the values of the rows or columns of the alignment matrix Takes O(n)
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < n; i++) {
    list.add(i);
return list;
HashMapcreateKeyValPair(List lst)
create Key Val Pair
HashMap<Long, T> ret = new HashMap<Long, T>();
Long rand;
for (T t : lst) {
    rand = Math.round(Math.random() * 1000000);
    ret.put(rand, t);
return ret;
voidcreateLimitSql(StringBuilder sql, Integer startNum, Integer rowNum, List params)
create Limit Sql
if (null != startNum && null != rowNum) {
    sql.append(" LIMIT ?,?");
    params.add(startNum);
    params.add(rowNum);
} else if (null != rowNum) {
    sql.append(" LIMIT ?");
    params.add(rowNum);
ListcreateList(Iterator iterator)
create List
List list = new ArrayList();
while (iterator.hasNext())
    list.add(iterator.next());
return list;
ListcreateList()
create List
return new ArrayList<>();
ListcreateList(Class elementClass)
Uses java generics to create a new ArrayList that can contain elements of the specified elementClass.
return new ArrayList<T>();
ListcreateList(Class itemClazz, T... items)
Creates the list.
List<T> returnList = new ArrayList<T>();
for (T item : items) {
    returnList.add(item);
return returnList;
ListcreateList(Collection collection)
create List
return new ArrayList(collection);
ListcreateList(Collection collection)
Creates a new list from the given collection.
if (collection instanceof List) {
    return (List) collection;
List list = new ArrayList();
Iterator it = collection.iterator();
while (it.hasNext()) {
    list.add(it.next());
return list;
ListcreateList(Collection collection)
Returns a List implementation for any input collection
return Collections.list(Collections.enumeration(collection));