As was pointed out, there is no goto
in Java, but the keyword was reserved in case Sun felt like adding goto
to Java one day. They wanted to be able to add it without breaking too much code, so they reserved the keyword. Note that with Java 5 they added the enum
keyword and it did not break that much code either.
Although Java has no goto
, it has some constructs which correspond to some usages of goto
, namely being able to break
and continue
with named loops. Also, finally
can be thought of as a kind of twisted goto
.