| Author |
Can someone walk me through how I got this output?
|
matthew meltzer
Greenhorn
Joined: Sep 08, 2012
Posts: 24
|
|
the code is
And the output is
i=1, j=0
i=2, j=0
i=2, j=1
I'm just trying to understand how j remains 0 for the first two lines the program prints.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
I've added code tags to make the code easier to read.
Each time the outer loop runs, the inner loop "starts over." Therefore, it starts as j=0 for each new value of i.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
matthew meltzer
Greenhorn
Joined: Sep 08, 2012
Posts: 24
|
|
Jeanne Boyarsky wrote:I've added code tags to make the code easier to read.
Each time the outer loop runs, the inner loop "starts over." Therefore, it starts as j=0 for each new value of i.
That makes sense. Thank you.
And I thought I put code tags around it but must have forgotten. Sorry about that!
|
 |
 |
|
|
subject: Can someone walk me through how I got this output?
|
|
|