-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestTools.java
More file actions
37 lines (34 loc) · 848 Bytes
/
TestTools.java
File metadata and controls
37 lines (34 loc) · 848 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
package leetcode;
/**
* By yize on 2015/1/4.
*/
public class TestTools {
public static void printList(ListNode head){
ListNode tmp = head;
while(tmp != null){
System.out.print(tmp.val + "->");
tmp = tmp.next;
}
System.out.println();
}
public static ListNode createList(int[] nums){
ListNode result = null;
ListNode tmp = null;
for(int i : nums){
if(result == null){
tmp = new ListNode(i);
result = tmp;
}else{
tmp.next = new ListNode(i);
tmp = tmp.next;
}
}
return result;
}
public static void printArray(int[] a){
for(int i : a){
System.out.print(i + " ");
}
System.out.println();
}
}