public class DoubleNode {
public int value;
public DoubleNode last;
public DoubleNode next;
public DoubleNode (int data){
value=data;
}
public static DoubleNode reverseDoubleList (DoubleNode head){
DoubleNode pre=null;
DoubleNode next=null;
while(head!=null){
next=head.next;
head.next=pre;
head.last=next;
pre=head;
head=next;
}return pre;
}
public static void main(String[] args) {
DoubleNode n = new DoubleNode(1);
DoubleNode m = new DoubleNode(2);
DoubleNode q=new DoubleNode(3);
n.last=null;
n.next=m;
m.last=n;
m.next=q;
q.last=m;
q.next=null;
System.out.println(reverseDoubleList(n).value);
}
}