这是我的代码,即时获取一个无法访问的语句错误,但我不知道为什么。为什么此代码给出“无法访问的声明”错误?
public boolean Boardload(String[] args) throws Exception
{
Robot robot = new Robot();
Color color3 = new Color(114, 46, 33);
Color color4 = new Color(180, 0, 0);
{
Rectangle rectangle = new Rectangle(0, 0, 1365, 770);
{
while(false)
{
BufferedImage image = robot.createScreenCapture(rectangle);
search: for(int x = 0; x < rectangle.getWidth(); x++)
{
for(int y = 0; y < rectangle.getHeight(); y++)
{
if(image.getRGB(x, y) == color3.getRGB())
{
return true;
}
}
}
}
}
return false;
}
}
确切的错误是:
java:68: unreachable statement
{
^
帮助将是很好,直到像素发现这个代码应该循环。
肯定的代码将不会进入循环“而(假)”(它永远不会计算为true,所以不会进入它)。那里的退货声明是否存在问题? – 2012-02-15 22:02:53
你知道虽然(false)什么都没做对吗? – BeRecursive 2012-02-15 22:03:17
哦不我觉得愚蠢的错误我在想什么 – user1179522 2012-02-15 22:06:20