+ 2

Can somebody helps me out to print the below pattern in java ?

#### # # # # ####

23rd Jun 2019, 9:38 AM
Shrikant M Benni
6 Respuestas
+ 3
Yes many can and will if you show us an attempt of yours and why are you posting other's codes with the question? Since you have access to CEO's post please read the rules for tags etc.
23rd Jun 2019, 10:00 AM
Daljeet Singh
Daljeet Singh - avatar
+ 3
that pattern will need 2 for-loops (-> one inside the other) this would be half the solution, try to finish it so you can improve 😁: int width = 4; int height = 4; for(int i=0;i<height;i++){ for(int j=0;j<width;j++){ if(i == 0 || j == 0){ System.out.print("#"); }else{ System.out.print(" "); } } System.out.print("\n"); //new Line }
23rd Jun 2019, 10:26 AM
Anton Böhler
Anton Böhler - avatar
+ 1
Type 3 and then 0 in the following code, you will get a similar output... https://code.sololearn.com/cTWPt2sX6W8Y/?ref=app Only replace 1 with #...
6th Jul 2019, 11:51 AM
mn121
mn121 - avatar
+ 1
mn121 isn't that quite a lot of code for such a simple pattern... 😅😅 int width = 4; int height = 4; for(int i=0;i<height;i++){ for(var j=0;j<width;j++){ if(i == 0 || j == 0 || i == height-1 || j == width-1){ System.out.print("#"); }else{ System.out.print(" "); } } System.out.print("\n"); }
6th Jul 2019, 12:32 PM
Anton Böhler
Anton Böhler - avatar
+ 1
Anton Böhler I asked to check case 3 only not the whole program😁😁😁... for(i=1;i<=4;i++) { for(j=1;j<=4;j++) { if(j==1||j==4||i==1||i==4) System.out.print("#"); else System.out.print(" "); } System.out.println(); }
6th Jul 2019, 12:47 PM
mn121
mn121 - avatar
+ 1
mn121 got carried away 😂😂😂
6th Jul 2019, 1:22 PM
Anton Böhler
Anton Böhler - avatar