Reverse a singly linked list. [java] view plain copy /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNode reverseList(ListNode head) { ListNode h = new ListNode(0); while(head!=null){ ListNode n = head.next; head.next = h.next; h.next = head; head = n; } return h.next; } } 原文链接http://blog.csdn.net/crazy__chen/article/details/46388327