From 841744e71f1c3271da6c0bb3af6ad982a029091a Mon Sep 17 00:00:00 2001 From: Khushi-Sarawagi Date: Tue, 29 Oct 2024 17:58:13 +0530 Subject: [PATCH] Hollow Diamond in java Pattern for Hollow Diamond in Java --- Java/HollowDiamond.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Java/HollowDiamond.java diff --git a/Java/HollowDiamond.java b/Java/HollowDiamond.java new file mode 100644 index 0000000..752decc --- /dev/null +++ b/Java/HollowDiamond.java @@ -0,0 +1,36 @@ +public class hollow { + public static void main(String[] args){ + Scanner sc=new Scanner(System.in); + int n=sc.nextInt(); + +// First half of the pattern + for(int i=1;i<=n;i++){ + + for(int j=n-i;j>=0;j--){ + System.out.print("*"); + } + + for(int k=2*(i-1);k>0;k--){ + System.out.print(" "); + } + for(int l=n-i;l>=0;l--){ + System.out.print("*"); + } + System.out.println(); + } +//Second half of the pattern + for(int i=0;i0;k--){ + System.out.print(" "); + } + for(int m=0;m<=i;m++){ + System.out.print("*"); + } + System.out.println(); + } + } + +}