On Sep 26, 2:28 am, Pravglad <[email protected]> wrote:
> for(int i = 1;i <= 5;i++){
>       for(int j = 1;j <= i;j++)
>
> can someone explain me how this works please
Very simply:
i = 1 j= 1
i = 1 j = 2
...
i = 1 j = 5

i = 2 j = 1
...
i = 2 j = 5

...

i = 5 j = 1
...
i = 5 j = 5

The most inner loop's variable iterates while the just above it loop's
variable retains its value. And this whatever number of nested loops
you may have.

Michèle Garoche

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to