File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ // deque implementation using LinkedList
2+ import java .util .*;
3+
4+ public class Linkedlistdeque
5+ {
6+ static Scanner sc = new Scanner (System .in );
7+ public static void main (String [] args ) {
8+ Deque <Integer > deque = new LinkedList <Integer >();
9+ for (int i =0 ;i <6 ;i ++){
10+ deque .add (sc .nextInt ());
11+ }
12+ System .out .println (deque );
13+ // add at the last
14+ deque .add (344 );
15+ // add at the first
16+ deque .addFirst (77 );
17+ // add at the last
18+ deque .addLast (89 );
19+ // add at the first
20+ deque .push (56 );
21+ // add at the last
22+ deque .offer (90 );
23+ // add at the first
24+ deque .offerFirst (800 );
25+ System .out .println (deque );
26+ // remove First
27+ deque .removeFirst ();
28+ // remove Last
29+ deque .removeLast ();
30+ System .out .println (deque );
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments