Skip to content

Commit

Permalink
implementation of stack provided by Java
Browse files Browse the repository at this point in the history
  • Loading branch information
NirmalSilwal committed Sep 5, 2020
1 parent b2355d6 commit 40bd17d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions CodingBlocks Training/Day16/inbuiltStack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package Lecture16;

import java.util.Stack;

public class inbuiltStack {

public static void main(String[] args) {

Stack<Integer> stack = new Stack<Integer>();

stack.push(10);
stack.push(20);
stack.push(30);
stack.push(40);
stack.push(50);

System.out.println(stack.peek()); // 50

while (!stack.isEmpty()) {
System.out.println(stack.pop());
}
}

}

/*
output:
50
40
30
20
10
*/

0 comments on commit 40bd17d

Please sign in to comment.