File tree Expand file tree Collapse file tree 2 files changed +15
-27
lines changed
Expand file tree Collapse file tree 2 files changed +15
-27
lines changed Original file line number Diff line number Diff line change 1616 * Time: 1:56 PM
1717 */
1818public class QueueUsingStack {
19- Stack <String > stack1 = new Stack <String >();
20- Stack <String > stack2 = new Stack <String >();
19+
20+ private Stack <String > stack1 = new Stack <>();
21+ private Stack <String > stack2 = new Stack <>();
2122
2223 public void add (String temp ) {
2324 stack1 .push (temp );
@@ -31,4 +32,16 @@ public String remove() {
3132 }
3233 return stack2 .pop ();
3334 }
35+
36+ public static void main (String [] args ) {
37+ QueueUsingStack queueUsingStack = new QueueUsingStack ();
38+ queueUsingStack .add ("A" );
39+ queueUsingStack .add ("B" );
40+ queueUsingStack .add ("C" );
41+ System .out .print (queueUsingStack .remove ());
42+ System .out .print (queueUsingStack .remove ());
43+ queueUsingStack .add ("D" );
44+ System .out .print (queueUsingStack .remove ());
45+ System .out .print (queueUsingStack .remove ());
46+ }
3447}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments