Skip to content

Commit d4c2f4d

Browse files
author
rpanjrath
committed
Stacks: Updating Queue using Stacks problem.
1 parent ed6e57c commit d4c2f4d

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

src/stackqueues/queueusingstack/QueueUsingStack.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
* Time: 1:56 PM
1717
*/
1818
public 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
}

src/stackqueues/test/TestStackQueue.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)