Sword refers to offer: merge two sorted linked lists (java)

package linkedList;

/**
 * 题目:(合并两个排序的链表)
 *      输入两个递增排序的链表,合并这两个链表并使新链表
 *      仍然是递增排序的。
 *      例如:
 *           链表1:1-3-5
 *           链表2:2-4-6
 *           合并之后:
 *              1-2-3-4-5-6
 */
public class P145_MergeTwoSortedLinkedlist {

    public ListNode MergerTwoSortedLinkedlist(ListNode list1, ListNode list2) {
        if (list1 == null) {
            return list2;
        }
        if (list2 == null) {
            return list1;
        }
        ListNode result = null;
        if (list1.val < list2.val) {
            result = list1;
            result.next = MergerTwoSortedLinkedlist(list1.next, list2);
        } else {
            result = list2;
            result.next = MergerTwoSortedLinkedlist(list1, list2.next);
        }

        return result;
    }

    public static void main(String[] args) {
        ListNode node1 = new ListNode(1);
        ListNode node2 = new ListNode(3);
        ListNode node3 = new ListNode(5);

        node1.next = node2;
        node2.next = node3;
        node3.next = null;

        ListNode node4 = new ListNode(2);
        ListNode node5 = new ListNode(4);
        ListNode node6 = new ListNode(6);

        node4.next = node5;
        node5.next = node6;
        node6.next = null;

        P145_MergeTwoSortedLinkedlist test = new P145_MergeTwoSortedLinkedlist();
        ListNode result = test.MergerTwoSortedLinkedlist(node1, node4);
        while (result != null) {
            System.out.print(result.val + " ");
            result = result.next;
        }
    }
}