+ 1

[Solved]Why isn't this java program working? Please help me.

https://code.sololearn.com/cI91WRmtFfJ6/?ref=app I made this code but nothing is working. I attempted to make a program that displays a Triangle pattern on screen using numbers. If I enter 6 it should display: 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 Please tell me the error thank you. Edit: I corrected the code! Original code: public class Program { public static void main(String[] args) { int i,z; int n=6; for(i=1;i<=n;i++) { for(z=1;z<=i;z++); { System.out.print(i+" "); } System.out.println(); } } }

5th Feb 2021, 2:08 PM
ltsRoy
ltsRoy - avatar
5 odpowiedzi
+ 7
The Problem that in your inner loop you hve added semicolon at loop. public class Program { public static void main(String[] args) { int i,z; int n=6; for(i=1;i<=n;i++) { for(z=1;z<=i;z++) { System.out.print(i+" "); } System.out.println(); } } }
5th Feb 2021, 4:15 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
It's Roy remove the semicolon after second for loop
5th Feb 2021, 2:15 PM
Abhay
Abhay - avatar
+ 1
💫💫 i think i said same, you could have corrected me for the spelling mistake atleast . I thought we had a awesome helpful community in here but all i see is people with many followers giving out their opinions (even when someone posted before) without correcting at all the others who are trying to help and believe me this is really toxic , no offense to you but just saying what i have been noticing.
5th Feb 2021, 9:12 PM
Abhay
Abhay - avatar
0
Thank you! 💫💫
5th Feb 2021, 8:18 PM
ltsRoy
ltsRoy - avatar
0
Ответ 🙏🙏🙏🙏
6th Feb 2021, 7:46 AM
Тайжукова Алтынай Рысбековна.
Тайжукова Алтынай Рысбековна. - avatar