+ 22
Doubt in output plss help.{Solved}
Can anybody plss tell how come the output is 66 for the following code?? class Test { public static void main(String[] args) { int i = 0, j = 9; do { i++; if (j-- < i++) { break; } } while (i < 5); System.out.println(i + "" + j); } }
8 ответов
+ 10
Suyash Pandey I already got the answer 2 months ago...😅
Thanks By the way 👍🙂
+ 3
1:
i = 0, j = 9
i = 1
if (9 < 1) // not true
break
i = 2, j = 8
2:
i = 2, j = 8
i = 3
if (8 < 3) // not true
break
i = 4, j = 7
3:
i = 3, j = 7
i = 4
if (7 < 4) // not true
break
i = 5, j = 6
4:
i = 5, j = 6
i = 6
if (6 < 6) // not true
break
i = 6, j = 6
in this while(i < 5) cause it to stop because i = 6
therefore i = 6, j = 6
0
RKK check your values for i in steps 3 and 4 again.
0
ChaoticDawg this is just an idea on how to dry code.
well the best option for this would be to use a debugger.
0
I understand what you're doing, just was trying to bring to your attention that there is a small error in your explanation. Check the value of I going into your step 3. It leaves step 2 with a value of 4, but you have it starting out at 3 in the next step. This makes it so that when the 3rd step is done it is 5 instead of 6. Step 4 doesn't actually happen.
0
Well I also don't get it sister
0
𝕊𝕠𝕝𝕠𝕝𝕖𝕒𝕣𝕟𝕖𝕣 okay 🙂....well....sista do you know anythin' 'bout hacking or ethical hacking?
0
𝕊𝕠𝕝𝕠𝕝𝕖𝕒𝕣𝕟𝕖𝕣 hey can you please say ....why if I am messaging anyone then it's showing you're not allowed!!