I have been trying to write simple return statements and print the result of the return. I have read books such as O-Reily and have used examples but find that the examples don't work either so I guess I just need human communication!!
First I have tried this return method - no errors:
public class recursiveTest {
public static int fact(int x)
{
x = 5;
if(x==1 || x==0) return x;
else {
return x * fact(x-1);
}
}
public static void main(String args[]){
}
}
Isn't the return supposed to print to system out? If it isn't I also wrote a method to print factorial(x) but that is usually an unreachable statement and a missing return. So how do you print the return value :icon_confused: ? Is anyone able to explain?