Most Asked Rhombus Pattern Program In Java

Below Java concepts are used to print that patterns

  • For Loop
  • While Loop
  • if..else

1). Program to print right Inclined Solid Rhombus using star(*) in Java

solid rhombus right inclined pattern program in c
import java.util.*;  
class Main{
    public static void main(String ...a){
    int i,j,k;
    Scanner sc= new Scanner(System.in);
    System.out.print("Enter the number of rows for Rhombus: ");  
    int n= sc.nextInt();  
    for(i=0;i<n;i++){
		for(k=1;k<n-i;k++){
                     System.out.print(" ");
	    }
	    for(j=0;j<=n;j++){
		        System.out.print("*");
		}
		 System.out.println("");
	    }
    }
} 

Output

Enter the number of rows for Rhombus: 5
    ******
   ******
  ******
 ******
******

2). Program to print left Inclined Solid Rhombus using star(*) in Java

solid rhombus left inclined pattern program in C
import java.util.*;  
class Main{
    public static void main(String ...a){
    int i,j,k;
    Scanner sc= new Scanner(System.in);
    System.out.print("Enter the number of rows for Rhombus: ");  
    int n= sc.nextInt();  
    for(i=n;i>=1;i--){
		    for(j=1;j<=n-i;j++){
                     System.out.print(" ");
		    }
		    for(k=1;k<=n;k++){
		        System.out.print("*");
		}
		 System.out.println("");
	    }
    }
} 

Output

Enter the number of rows for Rhombus: 5
*****
 *****
  *****
   *****
    *****

Leave a Comment