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 used? If it can not be used, then why was it included in Java as a keyword?
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 used? If it can not be used, then why was it included in Java as a keyword?
No, thankfully, there isn't
goto
in Java.The
goto
keyword is only reserved, but not used (the same goes forconst
).http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.goto
If you have been told that there is no goto statement in Java you have been fooled. Indeed, Java consists two layers of 'source' code.
To prevent people from being killed by velociraptors.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
goto is not in Java
you have to use GOTO But it don't work correctly.in key java word it is not used. http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
No,
goto
is not used in Java, despite being a reserved word. The same is true forconst
. Both of these are used in C++, which is probably the reason why they're reserved; the intention was probably to avoid confusing C++ programmers migrating to Java, and perhaps also to keep the option of using them in later revisions of Java.