Forums Register Login

Be The JVM (Head First)

+Pie Number of slices to send: Send
I don't understand how we got the output?!!
What's the first output in line 14? how do we calculate what's the value coming out of the loop? line 12?!





Answer is 13 15 x = 6
1
+Pie Number of slices to send: Send
In line #11 - you increment the value of y for every iteration in the for loop.

In line #12 - you check whether value of x is greater than 4. If so you increment the value of y.

In line #16 - you check whether value of y is greater than 14, If so then you use the break command to exit the for loop. Once a break is executed the for loop is terminated and the value of y will be 15 outside the for loop..

Try to run below program to understand it. If you work out with a pencil and paper you will understand it better.

+Pie Number of slices to send: Send
Thank you so much Sir,

Finally got it. had to read it a couple of times letter by letter.

Now i can go to bed
a wee bit from the empire
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1402 times.
Similar Threads
value of x?
head first java - mixed messages
how to compare the values in arrays
What is the output?
doubt in output(constructor related)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:34:38.