forked from super30admin/PreCourse-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (32 loc) · 1020 Bytes
/
Main.java
File metadata and controls
39 lines (32 loc) · 1020 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
31
32
33
34
35
36
37
38
39
//execution of all the implemented exercises.
public class Main {
public static void main(String args[])
{
Stack s = new Stack();
s.push(10);
s.push(20);
s.push(30);
System.out.println(s.pop() + " Exercise 1: Popped from stack");
//Excercise 2
StackAsLinkedList sll = new StackAsLinkedList();
sll.push(10);
sll.push(20);
sll.push(30);
System.out.println(sll.pop() + " Exercise 2: popped from stack");
System.out.println("Execise 2: Top element is " + sll.peek());
//Exercise 3
/* Start with the empty list. */
LinkedList list = new LinkedList();
//
// ******INSERTION******
//
// Insert the values
list = list.insert(list, 1);
list = list.insert(list, 2);
list = list.insert(list, 3);
list = list.insert(list, 4);
list = list.insert(list, 5);
// Print the LinkedList
list.printList(list);
}
}