小编use*_*522的帖子

返回外部方法错误

boolean openingboard;
{   
Robot robot = new Robot();
Color color3 = new Color(108, 25, 85);
Rectangle rectangle = new Rectangle(0, 0, 1365, 770);
    while(true)
    {
    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())
                {
                    System.out.println("About to finish and return true");
                    return true;
                }
                System.out.println("About to finish and return false");
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误是:java:71:返回外部方法

返回true

^

我不知道这是怎么回事请帮忙!

java methods return

8
推荐指数
2
解决办法
2万
查看次数

为什么此代码会出现"无法访问的语句"错误?

这是我的代码,我得到一个无法访问的语句错误,但我不知道为什么.

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;
    }
} 
Run Code Online (Sandbox Code Playgroud)

确切的错误是:

java:68: …
Run Code Online (Sandbox Code Playgroud)

java loops while-loop unreachable-code

0
推荐指数
1
解决办法
4362
查看次数

标签 统计

java ×2

loops ×1

methods ×1

return ×1

unreachable-code ×1

while-loop ×1