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
Because it's not supported and why would you want a goto
keyword that did nothing or a variable named goto
?
Although you can use break label;
and continue label;
statements to effectively do what goto
does. But I wouldn't recommend it.
public static void main(String [] args) {
boolean t = true;
first: {
second: {
third: {
System.out.println("Before the break");
if (t) {
break second;
}
System.out.println("Not executed");
}
System.out.println("Not executed - end of second block");
}
System.out.println("End of third block");
}
}