两个问题
(1)首结点next域指向null
(2)其余非空结点curr指向他们的前一个结点pre

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */
class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode pre = null;
        ListNode curr = head;
        while(curr!=null){
            ListNode temp = curr.next;
            curr.next = pre;
            pre = curr;
            curr = temp;
        }
        return pre;
    }
    

}

并附上某位大佬的三种解法。https://leetcode.com/problems/reverse-linked-list/discuss/228342/Java-solution-with-explanations-in-Chinese