-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMyStack.java
More file actions
45 lines (39 loc) · 1.2 KB
/
Copy pathTestMyStack.java
File metadata and controls
45 lines (39 loc) · 1.2 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package Week6.Lab6;
import java.util.Scanner;
/**
*
* @author szeyu
*/
public class TestMyStack {
public static void main(String[] args) {
MyStack<Character> stack = new MyStack<>();
// 1)
// b)
stack.push('a');
stack.push('b');
stack.push('c');
System.out.println(stack.toString());
System.out.println(stack.search('b'));
System.out.println(stack.search('k'));
// c)
stack.push('1');
stack.push('2');
stack.push('3');
System.out.println(stack.toString());
System.out.println(stack.search('6'));
// 2)
// a)
Scanner input = new Scanner(System.in);
System.out.print("Enter an integer value : ");
Character userIn = input.nextLine().charAt(0);
stack.push(userIn);
System.out.println("Size: " + stack.getSize());
while(!stack.isEmpty()){
System.out.println(stack.pop());
}
}
}