List of usage examples for java.util ArrayList add
public boolean add(E e)
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"); arrayList.add(1, "INSERTED"); for (String str : arrayList) System.out.println(str);//from w w w . j ava 2 s . c om }
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(15); arrlist.add(2);/* www . j ava 2 s .c o m*/ arrlist.add(2); arrlist.add(2); int retval = arrlist.size(); System.out.println("Size of list = " + retval); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> aList = new ArrayList<String>(); aList.add("1"); aList.add("2"); aList.add("3"); aList.add("4"); aList.add("java2s.com"); ListIterator<String> listIterator = aList.listIterator(); listIterator.next();//from w ww .jav a 2 s . c o m listIterator.add("Added Element"); for (String str : aList) { System.out.println(str); } }
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"); Object obj = arrayList.remove(1); System.out.println(obj + " is removed from ArrayList"); for (String str : arrayList) System.out.println(str);//from w w w. ja v a 2 s . co m }
From source file:Main.java
public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer>(10); arrlist.add(1); arrlist.add(2);//from w w w .j a v a 2s .co m arrlist.add(3); arrlist.add(4); arrlist.add(5); System.out.println(arrlist); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> aList = new ArrayList<String>(); aList.add("1"); aList.add("2"); aList.add("3"); aList.add("4"); aList.add("5"); ListIterator<String> listIterator = aList.listIterator(); listIterator.next();/* ww w.j a v a 2s .c o m*/ listIterator.add("Added Element"); for (String str : aList) { System.out.println(str); } }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("A"); arrayList.add("B"); arrayList.add("C"); arrayList.add("D"); arrayList.add("E"); System.out.println(arrayList); Collections.reverse(arrayList); System.out.println(arrayList); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("A"); arrayList.add("B"); arrayList.add("D"); System.out.println(arrayList); Collections.fill(arrayList, "REPLACED"); System.out.println(arrayList); }
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> arrayList = new ArrayList<Integer>(); arrayList.add(new Integer("1")); arrayList.add(new Integer("2")); arrayList.add(new Integer("3")); arrayList.add(new Integer("4")); arrayList.add(new Integer("5")); Object obj = Collections.min(arrayList); System.out.println(obj);//from w w w .j a va 2s. c om }
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"); arrayList.add("4"); arrayList.add("5"); Iterator itr = arrayList.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }//from w ww . ja v a 2s .c om }