主要就是保存前一个节点,当前节点,后一个节点,不断将当前节点指向指向前一个节点

public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}*/
public class Solution {
    public ListNode ReverseList(ListNode head) {
        if(head == null || head.next == null){
            return head;
        }
        ListNode pre = null ;
        ListNode currentNode = head;
        ListNode next = null;
        while(currentNode != null){
            next = currentNode.next;
            currentNode.next = pre;
            pre = currentNode;
            currentNode = next;
        }
        return pre;
    }
}