(ListNode listNode)
| 38 | } |
| 39 | |
| 40 | public static void print(ListNode listNode) { |
| 41 | if (listNode == null) { |
| 42 | System.out.println("null"); |
| 43 | return; |
| 44 | } |
| 45 | StringBuilder str = new StringBuilder("[" + String.valueOf(listNode.val)); |
| 46 | ListNode p = listNode.next; |
| 47 | while (p != null) { |
| 48 | str.append(",").append(String.valueOf(p.val)); |
| 49 | p = p.next; |
| 50 | } |
| 51 | System.out.println(str.append("]")); |
| 52 | } |
| 53 | } |