Does it help if you break things up with a lil bit of formatting and whitespace?
step through it line by line as if you were the JVM.
*Remember that in a
while statement -- you first run the
test -- then execute the code in the middle.
With a
do while you first execute the statement in the middle -- then run the test.*
outer loop test i++<3 TRUE (i=1)
prints j=0 inner loop test j++<3 TRUE (j=1)
prints j=1 inner loop test j++<3 TRUE (j=2)
prints j=2 inner loop test j++<3 TRUE (j=3)
prints j=3 inner loop test j++<3 FALSE(j=4)
outer loop test i++<3 TRUE (i=2)
prints j=4 inner loop test j++<3 FALSE(j=5)
outer loop test i++<3 TRUE (i=3)
prints j=5 inner loop test j++<3 FALSE(j=6)
outer loop test i++<3 FALSE(i=4)
END
.... its kinda like some country song I heard -- sometimes you're the windshield, sometimes you're the bug. With the SCPJ test -- sometimes you have to be the compiler, sometimes the JVM.
(ok... bad anaolgy -- but at least I tried) [ November 19, 2002: Message edited by: Jessica Sant ]