Java 标签中的语法错误

Java 标签中的语法错误,java,label,syntax-error,Java,Label,Syntax Error,这部分代码给我带来了麻烦: Iterator localIterator1; label75: Iterator localIterator2; if (str1 != null) { localIterator1 = localArrayList.iterator(); boolean bool = localIterator1.hasNext(); j = 0; if (bool) break label136; if

这部分代码给我带来了麻烦:

  Iterator localIterator1;
  label75: 
  Iterator localIterator2;
  if (str1 != null)
  {
    localIterator1 = localArrayList.iterator();
    boolean bool = localIterator1.hasNext();
    j = 0;
    if (bool)
      break label136;
    if (j == 0)
    {
      localIterator2 = localArrayList.iterator();
      label86: if (localIterator2.hasNext())
        break label215;
    }
  }
  while (true)
  {
    if (i != 0)
      MySpeechRecogonizer.this.position = 0;
    if ((j == 0) || (MySpeechRecogonizer.this.matchListener == null))
      break label404;
    MySpeechRecogonizer.this.matchListener.onSpeechMatch();
    return;
    label136:String str2 = (String)localIterator1.next();
    Log.e(MySpeechRecogonizer.this.TAG, str2 + MySpeechRecogonizer.this.target);
    if (!str2.trim().replace(" ", "").contains(MySpeechRecogonizer.this.target))
      break;
    j = 1;
    break label75;
    label215:
        String str3 = (String)localIterator2.next();

label215
label136
以及
label75
之后出现语法错误,需要分号或赋值运算符来完成语句。为什么会这样?

标签仅在两种情况下有效:

  • 在for循环、while循环或do while循环中使用时。例如:

在label75仍然给出相同错误的情况下工作。怎么可能呢?不过还是要谢谢你的帮助。。至少解决了一些问题,并且学会了
label:
for(int i = 0; i < listA.size(); i++)
{
    // doSomething
    while(someCondition)
    {
        // do another thing
        if(conditionA) continue label;
        if(conditionB) break label;
        // rest of code
    }
    // another code
}
label:
{
   // do something
   if(someCondition) break label;
   // rest of code
}