计数中断不起作用

时间:2015-01-18 23:17:50

标签: java infinite-loop reverting

关于为什么break在这里不起作用的任何想法?我需要让它工作,否则它会永远循环。

  int count = 0;           
  while (inputNumber != 0 )
  {
      int x = this.light.getDiameter();
      this.light.setDiameter(inputDiameter);
      changeColour();
      this.delay(100);
      this.light.setDiameter(x);
      changeColour();
      {
         count++;
      }
      if (count = inputNumber)
      {
         break;    // HERE: it was never reached. 
      }
   }

1 个答案:

答案 0 :(得分:2)

我会改变:

if (count = inputNumber)

if (count == inputNumber)