forked from dangtuanhuy/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackClass.java
More file actions
30 lines (25 loc) · 826 Bytes
/
Copy pathStackClass.java
File metadata and controls
30 lines (25 loc) · 826 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Session16_JavaDataStructure;
import java.util.Stack;
/**
*
* @author lhhuong
*/
public class StackClass {
public static void main(String[] args){
Stack s = new Stack();
s.push("Hello");
s.push("Bonjour");
s.push("Xin chao");
System.out.println("Your Stack: "+s);
//Kiem tra phan tu dau tien trong ngan xep
System.out.println("Element at the top: "+s.peek());
//Lay phan tu dau tien ra khoi ngan xep
System.out.println("Get the element at the top: "+s.pop());
System.out.println("New top element: "+s.peek());
}
}