List of usage examples for java.util ArrayList add
public boolean add(E e)
From source file:Main.java
/** * Converts the typed Array into a typed ArrayList * @param <T>//from w w w . jav a 2s . co m * @param tArray * @return */ public static <T> ArrayList<T> asArrayList(T[] tArray) { ArrayList<T> tList = new ArrayList<T>(); for (T t : tArray) { tList.add(t); } return tList; }
From source file:Main.java
static public ArrayList createArrayList(Object[] a) { ArrayList al = new ArrayList(a.length); for (int i = 0; i < a.length; i++) al.add(a[i]); return al;// w w w. ja v a 2 s . c om }
From source file:Main.java
public static final <T> List<T> collect(Iterator<? extends T> it) { ArrayList<T> r = new ArrayList<T>(); while (it.hasNext()) r.add(it.next()); return Collections.unmodifiableList(r); }
From source file:Main.java
public static <T> Collection<T> arrayToCollection(final T[] array) { int length = array == null ? 0 : array.length; ArrayList<T> al = new ArrayList<T>(length); for (int i = 0; i < length; i++) { al.add(array[i]); }//from w w w .j a v a 2s. co m return al; }
From source file:Main.java
/** convenience method to turn the given items into an arraylist */ public static <T> ArrayList<T> asList(T... items) { ArrayList<T> retval = new ArrayList<T>(); for (T item : items) { retval.add(item); }/*from w ww.ja va2s .co m*/ return retval; }
From source file:Main.java
public static <E> ArrayList<E> asArrayList(E first, E second, E... other) { if (other == null) { throw new NullPointerException("other"); }//from ww w .j a v a 2 s . c o m ArrayList<E> list = new ArrayList<>(1 + 1 + other.length); list.add(first); list.add(second); list.addAll(Arrays.asList(other)); return list; }
From source file:Main.java
public static ArrayList<String> formatDaysToTakeForObject(String string) { ArrayList<String> days = new ArrayList<>(); for (String s : string.split(" ")) { days.add(s); }/*w w w. j av a2s.c o m*/ return days; }
From source file:Main.java
public static <A, E extends A> A[] toArray(Enumeration<E> enumeration, A[] array) { ArrayList<A> elements = new ArrayList<A>(); while (enumeration.hasMoreElements()) elements.add(enumeration.nextElement()); return elements.toArray(array); }
From source file:Main.java
@SafeVarargs public static <T> ArrayList<T> newArrayList(T... values) { ArrayList<T> list = new ArrayList<T>(values.length); for (T t : values) { list.add(t); }//from w w w . j ava2 s . c o m return list; }
From source file:com.floreantpos.main.Main.java
public static void restart() throws IOException, InterruptedException, URISyntaxException { final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // Properties properties = System.getProperties(); // Set<Object> keySet = properties.keySet(); // for (Object object : keySet) { // PosLog.debug(getClass(),object + ":"+properties.getProperty((String) object)); // }/* w ww . j av a 2 s .co m*/ String classPath = System.getProperty("java.class.path"); //$NON-NLS-1$ String mainClass = System.getProperty("sun.java.command"); //$NON-NLS-1$ /* Build command: java -jar application.jar */ final ArrayList<String> command = new ArrayList<String>(); command.add(javaBin); command.add("-cp"); //$NON-NLS-1$ command.add(classPath); command.add(mainClass); final ProcessBuilder builder = new ProcessBuilder(command); builder.start(); System.exit(0); }