-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQue-50.java
More file actions
54 lines (54 loc) · 1.54 KB
/
Copy pathQue-50.java
File metadata and controls
54 lines (54 loc) · 1.54 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//Write a Program to demonstrate Stack class. Perform insert, delete and access operation.
//By: Parth Panjwani
import java.util.*;
class Que50 {
public static void main(String[] args) {
Stack<String> s = new Stack<String>();
s.push("A");
s.push("B");
s.push("C");
s.push("D");
s.push("E");
s.push("F");
s.push("G");
s.push("H");
s.push("I");
s.push("J");
s.push("K");
s.push("L");
s.push("M");
s.push("N");
s.push("O");
s.push("P");
s.push("Q");
s.push("R");
s.push("S");
s.push("T");
s.push("U");
s.push("V");
s.push("W");
s.push("X");
s.push("Y");
s.push("Z");
System.out.println("Elements in Stack are: ");
while (!s.isEmpty()) {
System.out.println(s.pop());
}
System.out.println("\nElements after deleting element at index 3: ");
s.pop();
while (!s.isEmpty()) {
System.out.println(s.pop());
}
System.out.println("\nElements after deleting element at index 5: ");
s.pop();
while (!s.isEmpty()) {
System.out.println(s.pop());
}
System.out.println("\nElements after deleting element at index 9: ");
s.pop();
while (!s.isEmpty()) {
System.out.println(s.pop());
}
System.out.println("\nElements after deleting element at index 15: ");
}
}