0
How to use nested loops in java
Can someone please help me with an explanation of how to use nested java code. I've tried the w3schools website but I can't quite get a grasp of it. Any help will be much appreciated
6 Respuestas
+ 3
Take a look at this and see if you can understand how it works
https://code.sololearn.com/c0eLJJ9S3PgP/?ref=app
+ 1
The parent loop runs 3 times, starts at zero, and up to two, because two is the biggest integer under 3, and the loop only executes if the counter is smaller than 3 because I decided so. This means that, whatever is inside the parent loop executes 3 times, the nested loop, does two iterations, but since the loop is executed 3 times by its parent, it loops its 2 times, finishes, and the parent executes it again, so it loops 2 more times and so on
0
What part exactly is giving you trouble? How nested for loops execute step by step?
0
I'm trying to iterate through the loops.. for loops to be precise
0
Thanks for the code explanation, but why does the nested for loop runs twice yet its parent only run once. They seem to be written the same way. Sorry for bothering you
0
Makes sense,, thanks a lot