Skip to content

Hollow Rhombus

Print a hollow rhombus pattern.

package DSA.Patterns;
public class hollowRhombus {
public static void hrhombus(int n) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= n; j++) {
if (j == 1 || i == 1 || j == n || i == n) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
public static void main(String[] args) {
hrhombus(5);
}
}