Java Utililty Methods List from

List of utility methods to do List from

Description

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

Method

ArrayListlistOfOne()
Create an array list of the given type of size 1.
return new ArrayList<T>(1);
ListlistOfOne(T x)
Answer a list containing the single object x.
List<T> result = new ArrayList<T>();
result.add(x);
return result;
ListlistOfStrings(int size, String prefix)
list Of Strings
ArrayList<String> list = new ArrayList<String>(size);
for (int i = 1; i <= size; i++)
    list.add(prefix + i);
return list;
StringlistOfStrToString(List src, String del)
list Of Str To String
StringBuilder sb = new StringBuilder();
for (String s : src)
    sb.append(s + del);
src.clear();
src = null;
return sb.toString();