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");
}
}
}
}
the error is:
java:71: return outside method
return true
^
i don’t know what this is happening please help!
From your comment response above, I am going to make the educated guess that you believe that
defines a Java method called
openingboard. This isn’t the case. Java follows the C paradigm of requiring you to specify your parameters in parentheses, regardless of whether you have any parameters or not. So, the methodis a valid Java method (assuming it is inside some class), as is a version of
openingboardwith much more code between the curly braces.That said, I’m going to pass along a few friendly pointers on Java style:
while (true), since those loops make it much harder to determine when the loop actually stops.searchin the code, and labels are even more discouraged than forever loops are.So, I would recommend rewriting your code to look something like
assuming of course that you prefer a debugger to trace prints.