“loop:” in Java code. What is this, and why does it compile?

后端 未结 12 1199
生来不讨喜
生来不讨喜 2020-11-22 08:02

This code just made me stare at my screen for a few minutes:

loop:
for (;;) {
    // ...
}

(line 137 here)

I have never seen this b

12条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 08:05

    It is a label. Generally a label used in Java to transfer the control flow at desired location while all keywords, like continue and break, have a specified choice of location.

提交回复
热议问题