Java Reference
In-Depth Information
3 . public static void stars( int n)
{
if (n <= 1)
{
System.out.print('*');
}
else
{
stars(n - 1);
System.out.print('*');
}
}
public static void backward( int n)
{
if (n < 10)
{
System.out.print(n);
}
else
{
System.out.print(n%10); //write last digit
backward(n/10); //write the other digits backward
}
}
4 . public static void writeUp( int n)
{
if (n >= 1)
{
writeUp(n - 1);
System.out.print(n + " "); //write while the
//recursion unwinds
}
}
5 . public static void writeDown( int n)
{
if (n >= 1)
{
System.out.print(n + " "); //write while the
//recursion winds
writeDown(n - 1);
}
}
6. An error message that says stack overflow is telling you that the computer has
attempted to place more stack frames on the stack than are allowed on your system.
A likely cause of this error message is infinite recursion.
Search WWH ::




Custom Search