File tree 4 files changed +35
-0
lines changed
4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 13
13
<maven .compiler.target>8</maven .compiler.target>
14
14
</properties >
15
15
16
+ <dependencies >
17
+ <dependency >
18
+ <groupId >junit</groupId >
19
+ <artifactId >junit</artifactId >
20
+ <version >4.13.1</version >
21
+ <scope >test</scope >
22
+ </dependency >
23
+ </dependencies >
24
+
16
25
</project >
Original file line number Diff line number Diff line change @@ -66,4 +66,13 @@ public int numberOfElements(){
66
66
return count ;
67
67
}
68
68
69
+ public String toString (){
70
+ StringBuilder result = new StringBuilder ();
71
+ Node tmp = head ;
72
+ while (tmp != null ) {
73
+ result .append (tmp ).append (" " );
74
+ tmp = tmp .getNext ();
75
+ }
76
+ return result .toString ();
77
+ }
69
78
}
Original file line number Diff line number Diff line change @@ -19,4 +19,8 @@ public int getData(){
19
19
return data ;
20
20
}
21
21
22
+ public String toString (){
23
+ return "" + data ;
24
+ }
25
+
22
26
}
Original file line number Diff line number Diff line change
1
+ import org .junit .Test ;
2
+
3
+ public class LinkedListTest {
4
+
5
+ @ Test
6
+ public void Test1 (){
7
+ LinkedList list = new LinkedList ();
8
+ list .insertFirst (new Node (4 ));
9
+ list .insertFirst (new Node (5 ));
10
+ list .insertFirst (new Node (6 ));
11
+ System .out .println (list .toString ());
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments