Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

goto keyword in java [duplicate]

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?

like image 555
Venkat Avatar asked Mar 30 '10 12:03

Venkat


1 Answers

James Gosling created the original JVM with support of goto statements, but then he removed this feature as needless. The main reason goto is unnecessary is that usually it can be replaced with more readable statements (like break/continue) or by extracting a piece of code into a method.

Source: James Gosling, Q&A session

like image 79
Vitalii Fedorenko Avatar answered Nov 07 '22 18:11

Vitalii Fedorenko