import java.io.*;
import java.util.*;
class Node{
int num;
Node next;
Node(int n){
num = n;
next = null;
}
}
class RecursivePrint{
public static void main(String[] args){
Node np, last;
Node top = null;
last = null;
for(int i = 1; i <11; i++){
np = new Node(i);
if(top==null)top = np;
else
last.next = np;
last = np;
}
recursiveprint(top);
}//end main
public static Node recursiveprint(Node top){
*Node newtop = null;*
* Node temp = null;*
* *
* if(top==null){*
* return null;*
* *
* }else{*
* temp = top;*
* top = top.next;*
* temp.next = newtop;*
* newtop = temp;*
* System.out.println(newtop.num);*
* return recursiveprint(newtop.next);* }
}//end recursive print
}//end class
in my reverse method when I try to reverse it only print 1 which indicates that it has stated the process and unable to complete. I try a while loop but it ran many times resulting in null output.