3
3
* To change this template file, choose Tools | Templates
4
4
* and open the template in the editor.
5
5
*/
6
-
7
6
package linkedlistimplementation ;
8
7
9
-
10
8
/**
11
9
*
12
10
* @author mac
@@ -18,8 +16,8 @@ public class LinkedListImplementation {
18
16
*/
19
17
public static void main (String [] args ) {
20
18
// TODO code application logic here
21
-
22
- /*SinglyLinkedList<Integer> myLinkedList = new SinglyLinkedList<Integer>();
19
+
20
+ /*SinglyLinkedList<Integer> myLinkedList = new SinglyLinkedList<Integer>();
23
21
myLinkedList.add(2);
24
22
myLinkedList.add(4);
25
23
myLinkedList.add(5);
@@ -74,17 +72,16 @@ public static void main(String[] args) {
74
72
myLinkedList.removeAt(myLinkedList.size() -1);
75
73
System.out.println("After removing value from last");
76
74
myLinkedList.printList();*/
77
-
78
- LinkedList myLinkedList = new LinkedList ();
79
- myLinkedList .addAtHead (1 );
75
+ LinkedList myLinkedList = new LinkedList ();
76
+ myLinkedList .addAtHead (1 );
80
77
myLinkedList .addAtTail (3 );
81
78
myLinkedList .addAtIndex (1 , 2 ); // linked list becomes 1->2->3
82
79
myLinkedList .get (1 ); // return 2
83
- System .out .println (myLinkedList .get (1 ));;
80
+ System .out .println (myLinkedList .get (1 ));;
84
81
myLinkedList .deleteAtIndex (1 ); // now the linked list is 1->3
85
82
myLinkedList .printList ();
86
- System .out .println (myLinkedList .get (1 ));;
87
-
83
+ System .out .println (myLinkedList .get (1 ));;
84
+
88
85
}
89
-
86
+
90
87
}
0 commit comments