dear all
I have a very simple java recursion which is worth to look at
the program runs but it gives same result even at different passed value ? !!
public class Simple {
public Simple() {
}
static int i = 0 ;
static String word ;
public static String read (String name) {
i++ ;
if (i < 3){
word = name ;
read (name) ;
}
System.out.println (“word “) ;
return word ;
}
public static void main(String[] args) {
String result1, result2 ;
result1 = read (“amir”) ;
System.out.println (result1) ;
result2 = read (“shankar”) ;
System.out.println (result2) ;
// why word shankar is not printed how to get it printed along with amir
System.out.println (result1) ;
System.out.println (result2) ;
}
}