Answer:
public static String makeLine (int n, char c) {
if (n ==0)
return "";
else
return (c + makeLine(n-1, c));
}
Explanation:
Create a method called makeLine that takes two parameters, int n and char c
If n is equal to 0, return an empty string
Otherwise, call the method with parameter n decreased by 1 after each call. Also, concatenate the given character after each call.
For example, for makeLine(3, '#'):
First round -> # + makeLine(2, '#')
Second round -> ## + makeLine(1, '#')
Third round -> ### + makeLine(0, '#') and stops because n is equal to 0 now. It will return "###".