List of usage examples for java.util ArrayDeque add
public boolean add(E e)
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25); deque.add(2);/* w w w . j a va 2 s . com*/ deque.add(1); deque.add(18); System.out.println(deque); // it will retrive element at first(head) position int retval = deque.element(); System.out.println("Retrieved Element is = " + retval); }
From source file:Main.java
public static void main(String[] args) { Collection<Integer> col = new ArrayList<Integer>(); col.add(0);//from w w w.jav a 2 s . c o m ArrayDeque<Integer> deque = new ArrayDeque<Integer>(col); deque.add(3); deque.add(18); deque.add(25); deque.add(18); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25); deque.add(2);// w ww . j a va2 s.com deque.add(1); deque.add(18); System.out.println(deque); int retval = deque.pollFirst(); System.out.println("Element removed is " + retval); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25); deque.add(2);//from w ww. ja v a2 s. c om deque.add(1); deque.add(18); System.out.println(deque); // getLast() will retrieve element at last position int retval = deque.getLast(); System.out.println("Retrieved Element is = " + retval); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3); deque.add(1);//w w w . j a v a2 s. co m deque.add(25); deque.add(18); System.out.println(deque); // printing the array length of elements added above Object[] ob = deque.toArray(); System.out.println("\n Array Size : " + ob.length); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3); deque.add(2);/*from w w w . j a v a 2s. co m*/ deque.add(1); deque.add(18); System.out.println(deque); // getFirst() will retrieve element at first(head) position int retval = deque.getFirst(); System.out.println("Retrieved Element is = " + retval); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25); deque.add(2);//from w w w . ja v a 2s . c o m deque.add(1); deque.add(18); // this will retrieve end value int retval = deque.peekLast(); System.out.println("Retrieved Element is " + retval); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25); deque.add(2);/*w w w. j a v a 2 s. c o m*/ deque.add(1); deque.add(18); System.out.println(deque); int retval = deque.pollLast(); System.out.println("Element removed is " + retval); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3); deque.add(1);/*from ww w . ja v a 2 s . c o m*/ deque.add(25); deque.add(4); System.out.println(deque); // this will print the size of this deque int retval = deque.size(); System.out.println("Size of deque = " + retval); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3); deque.add(1);/*from ww w. j a va 2 s .c om*/ deque.add(25); deque.add(18); System.out.println(deque); // printing the array length of elements added above Integer[] ob = deque.toArray(new Integer[deque.size()]); System.out.println("\n Array Size : " + ob.length); }