Horje
Hollow pyramid star pattern in java Code Example
Hollow pyramid star pattern in java
class hollowPyramid {
  public static void main(String[] args) {
    // size of the pyramid
    int size = 5;
    for (int  i = 0; i < size; i++) {
      // print spaces
      for (int j = 0; j < size - i - 1; j++) {
        System.out.print(" ");
      }
      // print stars
      for (int k = 0; k < 2 * i + 1; k++) {
        if (i == 0 || i == size - 1) {
          System.out.print("*");
        }
        else {
          if (k == 0 || k == 2 * i) {
            System.out.print("*");
          }
          else {
            System.out.print(" ");
          }
        }
      }
      System.out.println();
    }
  }
}




Java

Related
one space diagonally in java Code Example one space diagonally in java Code Example
fabricmc concat text Code Example fabricmc concat text Code Example
int to byte calculator Code Example int to byte calculator Code Example
java using the segment Information already before the for-loop Code Example java using the segment Information already before the for-loop Code Example
bigint is built in object Code Example bigint is built in object Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9