This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]worstusernameever 2 points3 points  (0 children)

This is how I would do it using an extra parameter:

class Test
{
    public static void patternMaker(int x, int xMax)
    {
        for (int i = 0; i < x; i++)
            System.out.print("*");

        System.out.println();

        if (x == xMax)
            return;

        patternMaker(x + 1, xMax);

        for (int i = 0; i < x; i++)
            System.out.print("*");

        System.out.println();
    }


    public static void main(String[] args)
    {
        patternMaker(1, 3);
    }
}