s******d 发帖数: 61 | 1 public void reverse(){
DoubleNode start=head;
DoubleNode temp=null;
while(head!=null){
temp=head.getNext();
head.setNext(head.prev);
head.setPrev(temp);
if(head.getPrev()==null){
head.setPrev(start);
break;
}
head=head.getPrev();
}
}
If I reverse onece, it prints successfully. While I reverse again, it prints
nothing.
Appreciate your help! |
|