List of usage examples for java.util ArrayList addAll
public boolean addAll(int index, Collection<? extends E> c)
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); Vector<String> v = new Vector<String>(); v.add("4");/*from ww w. j av a2 s . com*/ v.add("5"); // insert all elements of Vector to ArrayList at index 1 arrayList.addAll(1, v); for (String str : arrayList) System.out.println(str); }
From source file:Main.java
public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(1);//from ww w. ja va2 s.c o m arrlist.add(2); arrlist.add(4); System.out.println(arrlist); ArrayList<Integer> arrlist2 = new ArrayList<Integer>(5); arrlist2.add(25); arrlist2.add(30); arrlist2.add(31); arrlist2.add(35); System.out.println(arrlist2); // inserting all elements of list2 at third position arrlist.addAll(2, arrlist2); System.out.println(arrlist); }
From source file:com.draagon.meta.manager.ObjectManager.java
/** * Sorts the specified objects by the provided sort order *///from w w w . ja v a 2s. com @SuppressWarnings("unchecked") public static Collection<Object> sortObjects(Collection<Object> objs, SortOrder sort) throws MetaException { if (objs.size() == 0 || sort.getOrder() == SortOrder.NONE) return objs; ArrayList<Object> a = new ArrayList<Object>(); a.addAll(0, objs); ObjectComparator comp = new ObjectComparator(sort); Collections.sort(a, comp); return a; }