2015-04-04 104 views
-1

我有一个运行无限while循环的java应用程序。当我点击eclipse上的运行时,它似乎正在恢复到我已更改的旧代码。事情是,当我随机构建更新时。最近一次我添加System.exit()。我改变了代码,它仍然退出。我也在C#中试过这个程序。我觉得我在某种程度上将语言运行时与无限while循环混淆了。该程序适用于一系列不断变化的布尔值。我看到的反常行为(这是我添加System.exit()之前发生的事情)的主要操作是在迭代BufferedImage中的像素的方法中。我正在运行Ubuntu 14.10。我试图制作一个新项目并粘贴相同的代码(它可能是不可见的字符?)我很困惑,如果有人可以帮助,我会很高兴。Java编译错误的旧文件

while(true){ 
if (bool1 && !exe.isSeparate(image)) 
{ 
    // change boolean values 
    // did run System.exit(0) 
} 
if (bool2 && !exe.isSeparate(image)) 
{ 
    // change boolean values 
    // did run System.exit(0) 
} 
} 

boolean isSeparate(BufferedImage image) 
{ 
    int x = touchingX; 
    boolean first = false, second = false, third = false; 
    int startAt = this.getYStart(image); 
    for (int y = startAt; y < startAt + 150; y++) 
    { 
     Color pixel = new Color(image.getRGB(x, y)); 
     if (!(pixel.getRed() == 255 && pixel.getGreen() == 255 && pixel.getBlue() == 255) 
       && !(pixel.getRed() == 0 && pixel.getGreen() == 68 && pixel.getBlue() == 125)) 
     { 
      if (!first) 
      { 
       first = true; 
      } 
      if (first && second && !third) 
      { 
       third = true; 
      } 
     } 
     else 
     { 
      if (first && !second) 
      { 
       second = true; 
      } 
     } 
    } 
    if (first && second && third) 
    { 
     return true; 
    } 
    return false; 
} 

回答

0

我已经回答了我的问题。讽刺的是,这是一个逻辑错误。