private static Node head;
public static void reverseLinkedList() {
if(head == null || head.next == null) {
return;
}
Node p1 = head;
Node p2 = head.next;
Node p3 = null;
while(p2 = null) {
p3 = p2.next;
p2.next = p1;
p1 = p2;
p2 = p3;
}
head.next = null;
head = p1;
}
原文:https://www.cnblogs.com/shaonianteng/p/10387504.html