user1143305
user1143305

Reputation:

Label is missing error eclipse

 float f1 = 4.0F;
  localPaint.setTextSize(f1);
  int j = howManyBreaks(str, localPaint, paramInt1);
  int i = 0;
  while (true)
  {
    if ((f1 >= f2) || (j > paramInt2))
      break label142;    //getting error here
    i = 1;
    f1 += 0.5F;
    if (f1 >= f2)
      break;
    localPaint.setTextSize(f1);
    j = howManyBreaks(str, localPaint, paramInt1);
  }
  f1 = f2;
  if (i != 0)
    label142: f1 = f1 - 0.5F - 0.5F;   // but i have placed label142 here
  paramTextView.setTextSize(0, f1);

In this above code I get error as: "label142 is missing" Can anyone please rectify this error, if not possible please tell me an alternative for this. Thanks in advance

Upvotes: 2

Views: 4149

Answers (2)

mohdajami
mohdajami

Reputation: 9680

label142 is inside the IF statement it should be before the While if you want it break the loop just use break

Also, goto label is not a good option in programming, it makes the complex and hard to read, let alone maintain, try to avoid it.

Upvotes: 1

Amos M. Carpenter
Amos M. Carpenter

Reputation: 4958

You really should be avoiding labels... google "goto considered harmful".

Your problem is that your label is in an if-block, so it's not available from where you're trying to call it.

Upvotes: 1

Related Questions