I would like for my program to be in the shape of a triangle with space in between like the photo below. Heres my code so far.
import java.util.Scanner;
public class Triangle {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String space= " ";
space.replaceAll("", " ");
int i = input.nextInt();
while (i > 0) {
for (int j = 0; j <1; j++)
System.out.print("*"+space.substring(0,0)+"*");
System.out.println();
i--;
}
}
when i run this code the output is this
**
**
**
**
**
**
**
**
**
I would like the output to look like this: