-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoublyLinkedList.java
More file actions
44 lines (32 loc) · 1.26 KB
/
DoublyLinkedList.java
File metadata and controls
44 lines (32 loc) · 1.26 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
public class DoublyLinkedList {
public static void main(String[] args) {
// Initializing Objects
Student saon = new Student("Saon", "Sikder", 2502);
Student sakib = new Student("Sakib", "Al Hasan", 2505);
Student muaz = new Student("Md", "Muaz", 2517);
Student momenatul = new Student("Momenatul", "Islam", 2522);
Student anamul = new Student("Anamul", "Haq", 2523);
// adding references to the list
StudentLinkedList list = new StudentLinkedList();
list.addFront(saon);
list.addFront(sakib);
list.addFront(muaz);
list.addFront(momenatul);
list.addFront(anamul);
list.printList();
System.out.println("Size is: " + list.getSize());
// adding a new student at the end
Student iAmEnd = new Student("I'm", "End", 3000);
list.addToEnd(iAmEnd);
list.printList();
System.out.println("Size is: " + list.getSize());
// removing from the FRONT
list.remvoeFromFront();
list.printList();
System.out.println("Size is: " + list.getSize());
// removing from the END
list.removeFromEnd();
list.printList();
System.out.println("Size is: " + list.getSize());
}
}