File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Doubt:control flow working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt:control flow working" Watch "Doubt:control flow working" New topic

Doubt:control flow working

mansi gupte
Ranch Hand

Joined: Dec 30, 2008
Posts: 72

can some please explain the working of this code?

harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
Actually the output what iam geting is

and my explanation is dat

while your i becomes 3 continue from start...but at that time i will remain 3 won't reinitialize and it becomes
4 because of i++
then count becomes 3 and break start means control will leave out of the iterator..i mean control will go to the code just after that for loop..

now it will print the colours[3] and its green

SCJP 1.5
"A candle looses nothing by lighting another candle"
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
I hope you are not trying to tell us that labelled continue is good programming practice.
I agree. Here's the link:
subject: Doubt:control flow working
It's not a secret anymore!