package com.imust; class Node { public int value; public Node next; public Node(int data) { this.value = data; } } public class ReverseList { public static void reverseList(Node head) { if (head == null || head.next == null) return; Node pre = null;//先前节点 Node next = null;//临时节点 while (head != null) { next = head.next; head.next = pre; pre = head; head = next; } } }
https://www.bilibili.com/video/av49762694?from=search&seid=8970664744949276024