Java doesn't have a 'goto'
JAVA USES 'LABEL'.
example:
There is no goto e (though the the keyword is reserved), but break
and continue statements cause unconditional branching in more
restrictive contexts. You can combine them with statement labels to
achieve many of the effects that it is reasonable to want goto for. As
Stefan Ram pointed out, a switch block or a throw statement also produce
branching. So does a try/catch/finally, an if, a for or while loop, or
a method invocation.
It would be better if you can design your program so it not need to use a goto statement because it was considered not as a good practice in programming.
JAVA USES 'LABEL'.
example:
labelA: // some loop { continue labelA; }
There is no goto e (though the the keyword is reserved), but break
and continue statements cause unconditional branching in more
restrictive contexts. You can combine them with statement labels to
achieve many of the effects that it is reasonable to want goto for. As
Stefan Ram pointed out, a switch block or a throw statement also produce
branching. So does a try/catch/finally, an if, a for or while loop, or
a method invocation.
It would be better if you can design your program so it not need to use a goto statement because it was considered not as a good practice in programming.
No comments:
Post a Comment