Question: ```
public class Studying {
    public static void main(String[] args) {
        for (int i= 0; i<=5; i++){
            for (int q = 4-i; q>=0;){
                System.out.print(" ");
            }
            for (int w= i; w>0; w++ ){
                System.out.print("*");
            }
            System.out.print("*");

            for (int w= i; w<=4; w++ ){
                System.out.print("*");
            }
            for (int q = 4-i; q>=0;){
                System.out.println(" ");
            }
        }
    }
}

```

I am trying to create a triangle using \* but there seems to be a continuous loop and I can't figure out where the problem is.

Answer: 
```
 for (int i = 0; i < 5; i++) 
   System.out.println("    *********".substring(i, 5 + 2*i));

```

Result:

```
    *
   ***
  *****
 *******
*********

```
Ex:

```
      *
     ***
    *****
   *******
  *********

```

Code:

```
int numberOfRows = 5;

for(int i=0; i<numberOfRows; i++)
{
    for(int a=0; a<=numberOfRows; a++)
    {
        int x = numberOfRows - i;

        if (a > x) {
           System.out.print("*");
        } else {
           System.out.print(" ");
        }
    }

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

    System.out.print("\n");
}

```