File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ // Java code to illustrate iterator()
3
+ import java .util .*;
4
+
5
+ public class ArrayDequeDemo {
6
+ public static void main (String args [])
7
+ {
8
+ // Creating an empty ArrayDeque
9
+ Deque <String > de_que = new ArrayDeque <String >();
10
+
11
+ // Use add() method to add elements into the Queue
12
+ de_que .add ("Welcome" );
13
+ de_que .add ("To" );
14
+ de_que .add ("Geeks" );
15
+ de_que .add ("4" );
16
+ de_que .add ("Geeks" );
17
+
18
+ // Displaying the ArrayDeque
19
+ System .out .println ("ArrayDeque: " + de_que );
20
+
21
+ // Creating an iterator
22
+ Iterator value = de_que .iterator ();
23
+
24
+ // Displaying the values after iterating through the Deque
25
+ System .out .println ("The iterator values are: " );
26
+ while (value .hasNext ()) {
27
+ System .out .println (value .next ());
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments