List of usage examples for java.util ArrayList ArrayList
public ArrayList(Collection<? extends E> c)
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(15);/* ww w . j a v a 2 s . co m*/ arrlist.add(20); arrlist.add(25); System.out.println(arrlist); }
From source file:Main.java
public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(10);// www . java 2 s . co m arrlist.add(50); arrlist.add(30); arrlist.ensureCapacity(5000); }
From source file:Main.java
public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer>(10); arrlist.add(1);/*from ww w . j a va 2 s . c o m*/ arrlist.add(2); 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<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(15);//from w ww.j av a 2s .c om arrlist.add(2); 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<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(25);/* w ww.j a va 2s . c o m*/ boolean retval = arrlist.isEmpty(); if (retval == true) { System.out.println("list is empty"); } else { System.out.println("list is not empty"); } }
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(15);//from w ww. j ava2s. c o m arrlist.add(22); arrlist.add(30); arrlist.add(40); // adding element 25 at third position arrlist.add(2, 25); System.out.println(arrlist); }
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(15);//ww w .j a va 2 s . co m arrlist.add(22); arrlist.add(30); arrlist.add(40); System.out.println(arrlist); // retrieves element at 4th postion int retval = arrlist.get(3); System.out.println("Retrieved element is = " + retval); }
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(1);//from w w w.j av a 2s . co m arrlist.add(2); arrlist.add(2); arrlist.add(2); System.out.println(arrlist); // change element to 55 at 3rd position arrlist.set(2, 55); System.out.println(arrlist); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrlist = new ArrayList<String>(5); arrlist.add("G"); arrlist.add("E"); arrlist.add("F"); arrlist.add("M"); arrlist.add("from java2s.com"); System.out.println("Size of list: " + arrlist.size()); System.out.println(arrlist);/*from w w w . j a va2 s .c o m*/ // retrieving the index of element "E" int retval = arrlist.indexOf("E"); System.out.println("The element E is at index " + retval); }
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(20);//from w ww .j ava 2s. c om arrlist.add(15); arrlist.add(30); arrlist.add(45); System.out.println("Size of list: " + arrlist.size()); System.out.println(arrlist); arrlist.remove(2); System.out.println("Size of list: " + arrlist.size()); System.out.println(arrlist); }