Dollar characters

Report a typo

Given a recursive method that prints the dollar characters.


public static void printDollars(int n) {
    if (n > 1) {
        printDollars(n - 1);
    }
        
    for (int i = 0; i < n; i++) {
        System.out.print("$");
    }
}

How many characters will be printed if we call the method as:

printDollars(7);
Enter a number
___

Create a free account to access the full topic