Flow-control structures: Difference between revisions
Content added Content deleted
m (Speling/grammar/aesthetics) |
|||
Line 180: | Line 180: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
"goto" is a reserved keyword in Java; but you cannot use it. There are currently no goto statements. |
|||
===goto=== |
|||
Goto's are generally disliked, but they're still in the language so you can use them if you want. |
|||
public static void main(String[] args){ |
|||
inputStuff(); |
|||
if(someStaticVariable == someSpecialValue){ |
|||
goto skip; |
|||
} |
|||
//this code is skipped if the goto is executed |
|||
someOtherMethod(anotherVariable); |
|||
crazyAlgorithm(); |
|||
skip: |
|||
//this code is never skipped |
|||
finish(); |
|||
System.out.println("YOU WIN!"); |
|||
} |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |