Java tutorial
import java.util.ArrayDeque; import java.util.Deque; public class Main { public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(5); deque.add(25); deque.add(2); deque.add(35); deque.addFirst(10); deque.addFirst(3); deque.addFirst(1);//now, element 1 will be at the front deque.add(45); deque.add(40); System.out.println(deque); } }