Is there a goto statement in Java?

前端 未结 23 2513
醉酒成梦
醉酒成梦 2020-11-22 04:50

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

23条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 05:39

    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

提交回复
热议问题