-
Notifications
You must be signed in to change notification settings - Fork 0
/
Learn_Array_dequeue.java
26 lines (25 loc) · 1.05 KB
/
Learn_Array_dequeue.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Java_Collections_Framework;
// dequeue- it is a double ended key. you can remove the element from front as well as from the end
//& put the element from as well as the end & we can peek from both the sided.
// it is used in the sliding window.
// Operations- offer , add , offerFirst , offerLast, poll, pollFirst , pollLast;
import java.util.*;
public class Learn_Array_dequeue {
public static void main(String[] args) {
ArrayDeque<Integer>adq=new ArrayDeque<>();
adq.offer(2);
adq.offerFirst(9);// it adds the element in the first starting
adq.offerLast(1);// it adds the element in the last
adq.offer(98);
System.out.println(adq);
System.out.println(adq.peek());
System.out.println(adq);
System.out.println(adq.peekLast());
System.out.println(adq.poll());
System.out.println(adq);
System.out.println(adq.pollFirst());
System.out.println(adq);
System.out.println(adq.pollLast());
System.out.println(adq);
}
}