GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java ArrayDeque Class
Selected Reading
Java ArrayDeque ClassIntroductionThe Java ArrayDeque class provides resizable-array and implements the Deque interface. Following are the important points about Array Deques −
This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces. ArrayDeque Class DeclarationFollowing is the declaration for java.util.ArrayDeque class − public class ArrayDeque<E> extends AbstractCollection<E> implements Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, Queue<E> Here <E> represents an Element, which could be any class. For example, if you're building an array deque of Integers then you'd initialize it as − Deque<Integer> objDeque = new ArrayDeque<>(); ArrayDeque Class Constructors
ArrayDeque Class Methods
Adding and Removing Elements from an ArrayDeque ExampleThis Java example demonstrates how you can use an ArrayDeque Class. // Importing classes
import java.util.ArrayDeque;
import java.util.Deque;
// Public Main Class
public class Main {
public static void main(String[] args) {
// The main() function
Deque < Integer > objDeque = new ArrayDeque < > ();
// Adding elements at first and last
objDeque.addFirst(15);
objDeque.addLast(28);
// Removing the elements
int ele1 = objDeque.removeFirst();
int ele2 = objDeque.removeLast();
// Printing removed elements
System.out.println("First removed element is : " + ele1);
System.out.println("Last removed element is : " + ele2);
}
}
OutputThis will produce the following result − First removed element is : 15 Last removed element is : 28 Advertisements
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |