Goto statement in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Goto statement in java?

18th May 2018, 11:16 AM
Kanhaya Singh
Kanhaya Singh - avatar
5 Answers
+ 4
As far as I know, Java does not have a goto function. 'goto' is a reserved word, but it does not have an implementation. The Java documentation mentions the same: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
18th May 2018, 11:27 AM
Mickel
Mickel - avatar
+ 4
Here is an example of how you can implement something similar, although personally I do not see it as optimal. If you really need to use goto, I think you should rethink the logic behind your code. http://www.aboutcodes.com/2012/07/goto-statement-in-java-with-example.html
18th May 2018, 11:41 AM
Mickel
Mickel - avatar
0
thanks , but which feature in Java replace goto statment?
18th May 2018, 11:36 AM
Kanhaya Singh
Kanhaya Singh - avatar
0
Loops,break, continue and functions in some sense, also there is a goto instruction in the bytecode the jvm interprets
18th May 2018, 11:42 AM
Max
Max - avatar
0
thanks😊
18th May 2018, 11:43 AM
Kanhaya Singh
Kanhaya Singh - avatar