これは私のコードで、私はそれに到達できない文のエラーを取得していますが、私は理由を知らない。このコードが「到達不能なステートメント」エラーを出すのはなぜですか?
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
{
^
ヘルプがいいだろう、ピクセルが発見されるまで、このコードはループになっています。
確かに、コードは 'while(false)'というループに入りません(本当に評価されることはないので、入力しません)。問題の中のリターン・ステートメントは問題ですか? –
while(false)は何も正しくありません。 – BeRecursive
ああ私は思って何が愚かな虚偽を感じていない – user1179522