List of usage examples for java.util ArrayList add
public boolean add(E e)
From source file:Main.java
/** * create new ArrayList and copy from {@code src} to it. no effect to * {@code src}./* w ww .j a va 2s .c om*/ */ static public ArrayList<Long> new_array_list_from(long[] src) { final ArrayList<Long> dest = new ArrayList<Long>(src.length); for (long x : src) { dest.add(x); } return dest; }
From source file:Main.java
public static <T> ArrayList<T> convertPrimitiveArrayToList(T[] data) { ArrayList<T> ret = new ArrayList<T>(); for (int i = 0; i < data.length; i++) { ret.add(data[i]); }// www. j av a 2 s . c o m return ret; }
From source file:Main.java
public static ArrayList<String> getXAxisValues(int dataSize) { ArrayList<String> xAxis = new ArrayList<>(); for (int i = 0; i < dataSize; i++) { xAxis.add(String.valueOf(i + 1)); }//from ww w. j a v a 2 s. c om return xAxis; }
From source file:Main.java
public static ArrayList<Double> matrixMinus(ArrayList<Double> a1, ArrayList<Double> a2) { ArrayList<Double> res = new ArrayList<Double>(); for (int i = 0; i < a1.size(); i++) { res.add(a1.get(i) - a2.get(i)); }//w w w.j a v a 2s.c o m return res; }
From source file:Main.java
public static ArrayList<String> toStringArrayList(CharSequence[] strings) { ArrayList<String> list = new ArrayList<>(); for (CharSequence string : strings) { list.add(string.toString()); }/*from w w w . j a v a 2s . co m*/ return list; }
From source file:Main.java
public static ArrayList<String> copyArrayList(ArrayList<String> srcArrayList) { ArrayList<String> dstArrayList = new ArrayList<String>(); for (String ele : srcArrayList) dstArrayList.add(ele); return dstArrayList; }
From source file:Main.java
/** * Create a list from an enumeration//from ww w . j a v a2 s . co m * * @param e the enumeration * @return the list */ public static List list(Enumeration e) { ArrayList result = new ArrayList(); while (e.hasMoreElements()) result.add(e.nextElement()); return result; }
From source file:Main.java
public static <T> ArrayList<T> asArrayList(T... elements) { ArrayList<T> result = new ArrayList<T>(); for (T elem : elements) { result.add(elem); }/*from ww w .j a v a 2s . c o m*/ return result; }
From source file:Main.java
public static void ensureSize(ArrayList<?> collection, int size) { while (collection.size() < size) { collection.add(null); }/*from www . j a v a 2s.co m*/ }
From source file:Main.java
@Deprecated public static <T> List<T> asList(final T t, final T... ts) { final ArrayList<T> list = new ArrayList<T>(ts.length + 1); list.add(t); Collections.addAll(list, ts); return list;//from ww w .ja v a 2 s .c o m }