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

/**
 * Splits the string using a comma, creates and returns an array list of strings.
 * @param item/*from w  w w  .  j av  a  2  s.  co m*/
 * @return
 */
public static ArrayList<String> split(String item) {
    ArrayList<String> list = new ArrayList<String>();

    for (String i : item.split(","))
        list.add(i);

    return list;
}

From source file:Main.java

public static ArrayList<Byte> asArrayList(byte[] showtext2) {
    ArrayList<Byte> list = new ArrayList<Byte>();
    for (int i = 0; i < showtext2.length; i++) {
        list.add(showtext2[i]);
    }//from   w  ww.j a  va2s.  com
    return list;
}

From source file:com.orig.gls.branch.dao.Branch.java

public static ArrayList getAllBranches() {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction tx = null;/*from w  w  w  .j  a v  a 2s.  com*/
    ArrayList arr = new ArrayList();
    List<ServiceOutletTable> list;
    try {
        tx = session.beginTransaction();
        Criteria cr = session.createCriteria(ServiceOutletTable.class);
        cr.addOrder(Order.asc("solId"));
        list = cr.list();
        for (ServiceOutletTable sol : list) {
            ArrayList one = new ArrayList();
            one.add(String.valueOf(sol.getSolId()));
            one.add(sol.getSolDesc());
            one.add(sol.getBankId());
            arr.add(one);
        }
        tx.commit();
    } catch (Exception asd) {
        log.debug(asd.getMessage());
        if (tx != null) {
            tx.rollback();
        }
    } finally {
        session.close();
    }
    return arr;
}

From source file:com.orig.gls.seed.Currency.java

public static ArrayList getEnabledCurrencies() {
    ArrayList arr = new ArrayList();
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction tx = null;//from   w  w w  . j a  v  a2s  .  c o  m
    List<CurrencyCodes> currency;
    try {
        tx = session.beginTransaction();
        Criteria cr = session.createCriteria(CurrencyCodes.class);
        cr.add(Restrictions.eq("enabledFlg", "Y"));
        currency = cr.list();
        for (CurrencyCodes curr : currency) {
            ArrayList one = new ArrayList();
            one.add(curr.getCurrencyCode());
            one.add(curr.getCurerncyName());
            one.add(sdf.format(curr.getRcreTime()));
            arr.add(one);
        }
        tx.commit();
    } catch (Exception asd) {
        log.debug(asd.getMessage());
        if (tx != null) {
            tx.rollback();
        }
    }
    return arr;
}

From source file:Main.java

public static ArrayList<String> createStringArrayList(String... strings) {
    ArrayList<String> list = new ArrayList<String>(strings.length);
    for (String s : strings) {
        list.add(s);
    }/*  ww w  . j  a  v a  2s .c  o  m*/
    return list;
}

From source file:Main.java

public static String[] generateArrayWithStringValuesInRange(int min, int max) {
    ArrayList<String> arrayList = new ArrayList<>();
    for (int i = min; i < max; i++) {
        arrayList.add(Integer.toString(i));
    }/*from  w w w. j av a 2 s  .c o  m*/
    String[] stringArray = new String[arrayList.size()];
    for (int i = 0; i < arrayList.size(); i++) {
        stringArray[i] = arrayList.get(i);
    }
    return stringArray;
}

From source file:Main.java

public static <T> List<T> toList(T[] array) {
    if (array == null) {
        return new ArrayList<T>();
    }// w  ww  .  ja va  2 s  . c o m

    ArrayList<T> result = new ArrayList<T>();
    for (T item : array) {
        result.add(item);
    }

    return result;
}

From source file:Main.java

/**
 * Convert an Object array to a Collection
 * @param objectArray//  ww  w  .  j  a  v a2 s  . c  o m
 * @return
 */
public static Collection arrayToCollection(Object[] objectArray) {
    ArrayList conversion = new ArrayList();
    for (int i = 0; i < objectArray.length; i++) {
        conversion.add(objectArray[i]);
    }
    return conversion;
}

From source file:Main.java

public static List list(Iterator ite) {
    ArrayList ret = new ArrayList();
    while (ite.hasNext()) {
        Object o = ite.next();//from   w w  w .ja v a2 s . co  m
        ret.add(o);
    }
    return ret;
}

From source file:Main.java

public static <T> List<T> shallowCopyToList(Collection<T> collection) {
    ArrayList<T> copied = new ArrayList<T>(collection.size());
    for (T element : collection) {
        copied.add(element);
    }/* w  w w  .  j a  va2s  .co  m*/
    return copied;
}