Diamond Shape Pattern Program in Java
//Diamond Shape Pattern Program in Java
import java.util.Scanner;
public class Edureka
{
public static void main(String args[])
{
int n, i, j, space = 1;
System.out.print("Enter the number of rows: ");
Scanner s = new Scanner(System.in);
n = s.nextInt();
space = n - 1;
for (j = 1; j<= n; j++)
{
for (i = 1; i<= space; i++)
{
System.out.print(" ");
}
space--;
for (i = 1; i <= 2 * j - 1; i++)
{
System.out.print("*");
}
System.out.println("");
}
space = 1;
for (j = 1; j<= n - 1; j++)
{
for (i = 1; i<= space; i++)
{
System.out.print(" ");
}
space++;
for (i = 1; i<= 2 * (n - j) - 1; i++)
{
System.out.print("*");
}
System.out.println("");
}
}
}
Also in Java:
- open an existing excel file in java apache poi
- java random number
- substring in java
- java enum
- android java add new record to Firebase Firestore
- boolean java.lang.String.equals(java.lang.Object)' on a null object reference
- java stream sorted reverse
- loop collection android
- Diamond Shape Pattern Program in Java
- java change boolean to opposite
- java create file
- java binary exponentiation
- python vs java
- creating thread in java example
- java define a generic class that produces
- tower of hanoi program in java using recursion
- how to declare a linked list in java
- string replace last character java
- how to get all the names of the files in a folder in java?
- how to extract data from delimited text file in java
- How to draw Bezier Curve in Android
- java prev permutation
- how to make a dictionary in java
- throwing exceptions java