方法一:普通遍历 public class Test { public ListNode ReverseList(ListNode head) { //此处为了提高效率 可以进行null的拦截 if(null == head || null == head.next) return head; ListNode pre = null;//结果链表 ListNode cur = head;//中间指针 while(null != cur){ //临时指针 保证cur 可以正常移动 ListNode next = cur.next; //将cur指向右侧的指针 反转指向左侧 cur.next = pre; //将pre右移 pre = cur; //将cur右移 cur = next; } return pre; } public static void main(String[] args) { ListNode head = new ListNode(1); System.out.println(new Test().ReverseList(head).toString()); } } class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } ListNode(int val,ListNode next){ this.next = next; this.val = val; } @Override public String toString() { return "ListNode{" + "val=" + val + ", next=" + next + '}'; } } 方法二:使用栈的特性,先进后出