-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkedListDemo.java
46 lines (37 loc) · 1.1 KB
/
LinkedListDemo.java
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
46
package datastructures;
public class LinkedListDemo {
public static void main(String[] args) {
LinkedList list = new LinkedList();
list.insertAtHead(5);
list.insertAtHead(10);
list.insertAtHead(2);
list.insertAtHead(12);
list.insertAtHead(19);
list.insertAtHead(20);
list.deleteFromHead(); //deletes the 20
System.out.println(list);
System.out.println("Length: " + list.length());
list.deleteFromHead();
System.out.println(list);
list.insertAtHead(1000);
System.out.println(list);
list.insert(32, 3);
System.out.println("Hello World");
System.out.println(list);
System.out.println("Hello World");
//Stack demo
/*Stack stack = new Stack();
System.out.println(stack.isEmpty());
stack.push(7);
stack.push(5);
stack.push(6);
stack.push(10);
System.out.println(stack.isEmpty());
System.out.println(stack.peek()); //will output number twice because it peeks then pops
System.out.println(stack.pop());
System.out.println(stack.peek());
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.pop());*/
}
}