public static void printStars1(int lines)
{
if (lines > 0)
{
for (int i = 0; i < lines; i++)
System.out.print("*");
System.out.println();
printStars1 (lines - 1);
for (int i = lines; i > 0; i--)
System.out.print("*");
System.out.println();
}
}
It produces a pattern like this when called (when the main method enters the number of lines:
****
***
**
*
*
**
***
****
The other method is supposed to look like this:
*
**
***
****
****
***
**
*
I first thought I should change the parameters of my loop, but that didn't work. I then moved the recursive call to the beginning of the method, but that only makes the top half of the pattern. I feel like I am overlooking somethin simple. Can anyone point me in the right direction?
Thanks.

New Topic/Question
Reply




MultiQuote





|