-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCTest.java
More file actions
37 lines (31 loc) · 1.07 KB
/
SCTest.java
File metadata and controls
37 lines (31 loc) · 1.07 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
/**
* This class demonstrates the methods of the SCTest class.
* @author Ioannis Tzeneralis
* @version 1.0
*/
class SCTest {
/**
* This is the main method.
* @param args Unused.
*/
public static void main(String args[]) {
SC test = new SC(3);
test.push('5'); // inserting in the stack
test.push('1'); // inserting in the stack
test.push('3'); // inserting in the stack
System.out.println("The top element is " + test.peek());
System.out.println("The stack size is " + test.size());
test.pop(); // removing the top element
test.pop(); // removing the top element
System.out.println("The top element is " + test.peek());
System.out.println("The stack size is " + test.size());
test.pop(); // removing the top element
// check if the stack is empty
if (test.empty()) {
System.out.println("The stack is empty");
}
else {
System.out.println("The stack is not empty");
}
}
}