I\'m confused about this. Most of us have been told that there isn\'t any goto statement in Java.
But I found that it is one of the keywords in Java. Where can it be
I'm not a fan of goto
either, as it usually makes code less readable. However I do believe that there are exceptions to that rule (especially when it comes to lexers and parsers!)
Of Course you can always bring your program into Kleene Normalform by translating it to something assembler-like and then write something like
int line = 1;
boolean running = true;
while(running)
{
switch(line++)
{
case 1: /* line 1 */
break;
case 2: /* line 2 */
break;
...
case 42: line = 1337; // goto 1337
break;
...
default: running = false;
break;
}
}
(So you basically write a VM that executes your binary code... where line
corresponds to the instruction pointer)
That is so much more readable than code that uses goto
, isn't it?