@@ -0,0 +1,2224 @@
+import java.io.*;%0Aimport java.math.*;%0Aimport java.security.*;%0Aimport java.text.*;%0Aimport java.util.*;%0Aimport java.util.concurrent.*;%0Aimport java.util.regex.*;%0A%0Apublic class ReverseLinkedList %7B%0A%0A    static class DoublyLinkedListNode %7B%0A        public int data;%0A        public DoublyLinkedListNode next;%0A        public DoublyLinkedListNode prev;%0A%0A        public DoublyLinkedListNode(int nodeData) %7B%0A            this.data = nodeData;%0A            this.next = null;%0A            this.prev = null;%0A        %7D%0A    %7D%0A%0A    static class DoublyLinkedList %7B%0A        public DoublyLinkedListNode head;%0A        public DoublyLinkedListNode tail;%0A%0A        public DoublyLinkedList() %7B%0A            this.head = null;%0A            this.tail = null;%0A        %7D%0A%0A        public void insertNode(int nodeData) %7B%0A            DoublyLinkedListNode node = new DoublyLinkedListNode(nodeData);%0A%0A            if (this.head == null) %7B%0A                this.head = node;%0A            %7D else %7B%0A                this.tail.next = node;%0A                node.prev = this.tail;%0A            %7D%0A%0A            this.tail = node;%0A        %7D%0A    %7D%0A%0A    public static void printDoublyLinkedList(DoublyLinkedListNode node, String sep) %7B%0A        while (node != null) %7B%0A            System.out.print(String.valueOf(node.data));%0A            node = node.next;%0A            if (node != null) %7B%0A                System.out.print(sep);%0A            %7D%0A        %7D%0A    %7D%0A%0A    static DoublyLinkedListNode reverse(DoublyLinkedListNode head) %7B%0A        if (head == null) %7B%0A            return head;%0A        %7D%0A%0A        DoublyLinkedListNode next = head.next;%0A        head.next = head.prev;%0A        head.prev = next;%0A%0A        return head.prev == null ? head : reverse(head.prev);%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        DoublyLinkedList llist = new DoublyLinkedList();%0A%09%09llist.insertNode(1);%0A%09%09llist.insertNode(2);%0A%09%09llist.insertNode(3);%0A%09%09llist.insertNode(4);%0A%0A%09%09System.out.println(%22Original List:%22);%0A%09%09printDoublyLinkedList(llist.head, %22 %22);%0A%0A%09%09System.out.println(%22%22);%0A%09%09System.out.println(%22Reversed List:%22);%0A%0A        DoublyLinkedListNode reversedHead = reverse(llist.head);%0A        printDoublyLinkedList(reversedHead, %22 %22);%0A%0A        System.out.println(%22%22);%0A    %7D%0A%7D%0A

add reverse doubly linked list