ListNode res =new ListNode();
ListNode cur = res;
public ListNode reverseList(ListNode head) {
if (head != null && head.next != null) { reverseList(head.next); }
cur.next = head;
cur = cur.next;
**if(cur != null&&cur.next != null){ cur.next = null;}**这段代码如果不加入cur !=null就会出现空指针异常不知道为啥
return res.next;
}
}
reverseList(head.next) 改为 return reverseList(head.next);