I indicate the base case as emptySpace=0 and the else if condition has the base case as star=0. I was expecting that the program would print the spaces first after it prints the stars but the opposite situation happens. Shouldn't it print the spaces first then stars?
public static void displayStarss(int emptySpace, int star) {
if (emptySpace != 0) {
displayStarss(emptySpace - 1, star);
System.out.print(" ");
} else if (star != 0) {
displayStarss(emptySpace, star - 1);
System.out.print("*");
}
}
public static void main(String[] args) {
displayStarss(3, 3);
}