English 中文(简体)
Java搜索:“锁”
原标题:The Java search: "block"
  • 时间:2012-04-25 20:29:40
  •  标签:
  • java
  • search

是否有人在 Java看到以下情况?

public void methodName(){ 
   search:
     for(Type[] t : Type[] to){
       do something...
   }
}

Can someone point me to documentation on the use of "search:" in this context? Searching for "search:" has not been productive.

成就

最佳回答

页: 1 http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.7“rel=“noreferer” 。

声明可能有标签......

(略微克马,疼痛打上标记)

与C和C++不同, Java方案语言没有<代码>goto说明;识别标志标签用<代码>break(§ 14.15)或continue(§14.16)在标签说明中任何地方出现的声明。

你们经常看到的一个地方是nes,你可能希望尽早打破两处 lo:

void foo() {
    int i, j;

    outerLoop:                     // <== label
    for (i = 0; i < 100; ++i) {
        innerLoop:                 // <== another label
        for (j = 0; j < 100; ++j) {
            if (/*...someCondition...*/) {
                break outerLoop;   // <== use the label
            }
        }
    }
}

通常情况下,内 lo中的<条码>突破性将只会打破内 lo,而不会打破外部。 但是,由于它使用标签贴上了directed<>code>-break,因此它打破了外部循环。

问题回答

This is an example of a labelled loop.

本条允许你<条码>突破或<条码>连续<>。 而不是你目前的 lo。

Outer:
    for(int intOuter=0; intOuter < intArray.length ; intOuter++)
    {
      Inner:
      for(int intInner=0; intInner < intArray[intOuter].length; intInner++)
      {
        if(intArray[intOuter][intInner] == 30)
        {
          blnFound = true;
          break Outer; // this line breaks the outer loop instead of the inner loop.
        }  

      }
    }

http://www.java-examples.com/java-break-statement-label-example” rel=“nofollow” http://www.java-examples.com/java-break-statement-label-example

这是JLS中定义的 Java标签:





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签