0

問題を引き起こしているコードのこの部分があります。

  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();

の後に構文エラーが発生しlabel215label136さらにlabel75、ステートメントを完了するためにセミコロンが必要か、代入演算子が必要です。何故ですか?

4

1 に答える 1

1

ラベルは 2 つのコンテキストでのみ有効です。

  • for ループ、while ループ、または do-while ループ内で使用する場合。例えば:
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
}
于 2013-05-07T05:45:41.657 に答える