this method must return a result of type boolean, java

Solution 1:

Right now, the function isn't guaranteed to return a boolean, because it's possible that neither of the if statements will ever be entered.

You could fix it like this (but only do this if it's actually what your logic needs!):

public boolean Winner() {
    for (int z = 0; z < 3; z++) {
            if (board[z] != null && board[z] == board[z+3] && board[z] == board[z+6]
                    ) {
                return true;
            } 
    }
    for(int i=0; i<7;i+=3){
        if (board[i] != null && board[i] == board[i+1] && board[i] == board[i+2]) {

    return true;}
    }

    return false;
}

Solution 2:

The Java compiler doesn't make assumptions that a for loop will have an iteration or that an if statement block will run.

There are execution paths where there is no return statement. What happens if the execution path doesn't execute any of the existing return statements and drops to the bottom? There isn't a return there.

Add a return at the bottom.

Solution 3:

All possible ways that the method can exit need to return something. If your code makes it through both for loops without having an if condition evaluate to true, then you need a return at the end that specifies what gets returned.