-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack
More file actions
30 lines (27 loc) · 660 Bytes
/
Copy pathStack
File metadata and controls
30 lines (27 loc) · 660 Bytes
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
package edu;
import java.util.*;
public class Stackdemo {
public static void main(String[] args) {
// object of stack
Stack <Integer> stck = new Stack<>();
stck.push(10);
stck.push(20);
stck.push(30);
stck.push(40);
stck.push(50);
System.out.println("Stack before :" + stck);
stck.pop();
stck.pop();
System.out.println("Stack after :" + stck);
}
static void pushelmnt(Stack stck,int x) {
stck.push(new Integer(x));
System.out.println("push ->"+ x);
System.out.println("stack" + stck);
}
static void popelmnt(Stack stck) {
System.out.print("pop -> ");
Integer x = (Integer) stck.pop();
System.out.println("Stack "+ stck);
}
}