package linkedlist;

/**
 * http://leetcode.com/2010/04/reversing-linked-list-iteratively-and.html
 * Implement the reversal of a singly linked list iteratively and recursively.
 */
public class ReverseLinkedList {
    /**
     * Definition for singly-linked list.
     */
    private static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
            next = null;
        }
    }

    public ListNode reverseBetween(ListNode head) {
        return null;
    }
}

@@ -208,16 +208,641 @@
 dList %7B%0A
+    public static void main(String%5B%5D args) %7B%0A        ListNode head = new ListNode(1);%0A        head.next = new ListNode(2);%0A        System.out.println(head.toString());%0A%0A        ReverseLinkedList reverseLinkedList = new ReverseLinkedList();%0A        System.out.println(reverseLinkedList.reverse(head));%0A    %7D%0A%0A    public ListNode reverse(ListNode head) %7B%0A        if (head == null) return null;%0A%0A        ListNode prev = null, node = head;%0A        while (node != null) %7B%0A            ListNode next = node.next;%0A            node.next = prev;%0A            prev = node;%0A            node = next;%0A        %7D%0A%0A        return prev;%0A    %7D%0A%0A
     /**%0A
@@ -1054,87 +1054,157 @@
   %7D%0A
+%0A
     
-%7D%0A%0A
+    @Override%0A 
     
+   
 public 
-ListNode reverseBetween(ListNode head) %7B%0A        return null;
+String toString() %7B%0A            return String.valueOf(val) + (next == null ? %22%22 : %22,%22 + next.toString());%0A        %7D
 %0A   

implement reverse linked list