Example usage for java.util ArrayList add

List of usage examples for java.util ArrayList add

Introduction

In this page you can find the example usage for java.util ArrayList add.

Prototype

public boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:Main.java

public static ArrayList listModelToList(ListModel listmodel) {
    ArrayList togo = new ArrayList();
    for (int i = 0; i < listmodel.getSize(); ++i) {
        togo.add(listmodel.getElementAt(i));
    }/*from  ww  w  .  jav a2 s  .c om*/
    return togo;
}

From source file:Main.java

public static <T> T[] add(T[] current, T queueId) {
    ArrayList<T> asList = asList(current);
    asList.add(queueId);
    T[] result = current.clone();/*from w  ww  .  j a  v a2 s.co m*/
    return asList.toArray(result);
}

From source file:Main.java

public static <A, E extends A> A[] toArray(Enumeration<E> enumeration, A[] array) {
    ArrayList elements = new ArrayList();

    while (enumeration.hasMoreElements()) {
        elements.add(enumeration.nextElement());
    }/*from w w  w.  j a  v a  2 s.com*/

    return (A[]) elements.toArray(array);
}

From source file:Main.java

public static Collection<Integer> asList(int... data) {
    ArrayList<Integer> list = new ArrayList<Integer>(data.length);
    for (int i : data)
        list.add(i);
    return list;/*from  ww  w.j  a v a2s. co  m*/
}

From source file:Main.java

public static <T> ArrayList<T> arrayList(T... ts) {
    ArrayList<T> arrayList = new ArrayList<T>(ts.length);
    for (T t : ts) {
        arrayList.add(t);
    }//from   w w  w .  j  a  v  a 2 s .  co m
    return arrayList;
}

From source file:Main.java

/**
 * Creates <code>List</code> of <code>CollectionCertStores</code>
 *
 * @return The list created//from   w ww . j  a v a 2  s .  c o  m
 *
 * @throws InvalidAlgorithmParameterException
 * @throws NoSuchAlgorithmException
 */
public static List<CertStore> getCollectionCertStoresList()
        throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    CertStore cs = CertStore.getInstance("Collection", new CollectionCertStoreParameters());
    ArrayList<CertStore> l = new ArrayList<CertStore>();
    if (!l.add(cs)) {
        throw new RuntimeException("Could not create cert stores list");
    }
    return l;
}

From source file:Main.java

public static <T> java.util.ArrayList<T> ToList(Iterable<T> inList) {
    java.util.ArrayList<T> outList = new java.util.ArrayList<T>();
    for (T item : inList) {
        outList.add(item);
    }/*www .  ja  va2s  . c  om*/
    return outList;
}

From source file:Main.java

/**
 * Returns a truncated version of the specified <code>List</code>.
 * @param list the <code>List</code>
 * @param len the truncate length// w  w  w  .  ja v  a 2s .com
 * @return the truncated <code>List</code>
 */
public static List truncateList(List list, int len) {
    if (len >= list.size())
        return list;
    ArrayList newList = new ArrayList(len);
    for (int ii = 0; ii < len; ii++) {
        newList.add(list.get(ii));
    }
    return newList;
}

From source file:Main.java

public static ArrayList<Integer> integerRange(int min, int max) {
    ArrayList<Integer> beerValues = newArrayList();
    for (int i = min; i <= max; i++) {
        beerValues.add(i);
    }//w w w  . j a v  a 2s .  c o m
    return beerValues;
}

From source file:Main.java

public static <T> List<T> enumerationToList(Enumeration<T> theEnumeration) {
    ArrayList<T> retVal = new ArrayList<T>();
    while (theEnumeration.hasMoreElements()) {
        retVal.add(theEnumeration.nextElement());
    }//ww w .ja va2 s  .c om
    return retVal;
}