ok so im a new programmer and im making a tic tac toe program and i got this error"operator && cannot be applied to boolean,java.lang.String"
in the crazy long line in the winner method and am not sure how to fix it
import java.util.Scanner;
import java.util.Random;
public class tictactoe
{
public static void main(String[] args)
{
Scanner keyboard=new Scanner(System.in);
String[][] board= {{" "," "," "},{" "," "," "},{" "," "," "}};
int x=0;
int y=0;
int option=0;
String player1;
String player2;
System.out.println("Enter 1 for 2 player, or press 7 to exit");
option=keyboard.nextInt();
if (option==1)
{
System.out.println("Player 1 enter your name");
player1=keyboard.next();
System.out.println("Player 2 enter your name");
player2=keyboard.next();
boolean w=winner(board);
while (w==true||w==false)
{
System.out.println(player1+" enter your choice");
x=keyboard.nextInt();
y=keyboard.nextInt();
if (board[x][y]=="X")
{
System.out.println("That space is already taken");
continue;
}
if (board[x][y]=="Y")
{
System.out.println("That space is already taken");
continue;
}
board[x][y]="X";
displayBoard(board);
do
{
System.out.println(player2+" enter your choice");
x=keyboard.nextInt();
y=keyboard.nextInt();
if (board[x][y]=="X")
{
System.out.println("That space is already taken");
continue;
}
if (board[x][y]=="O")
{
System.out.println("That space is already taken");
continue;
}
board[x][y]="O";
displayBoard(board);
break;
}
while (true);
}
}
}
public static void displayBoard (String z[][])
{
System.out.println(" "+z[0][0]+" | "+z[0][1]+" | "+z[0][2]);
System.out.println(" ---------");
System.out.println(" "+z[1][0]+" | "+z[1][1]+" | "+z[1][2]);
System.out.println(" ---------");
System.out.println(" "+z[2][0]+" | "+z[2][1]+" | "+z[2][2]);
}
public static boolean winner (String z[][])
{
if (z[0][0]=="X"&&z[0][1]=="X"&&z[0][2]=="X"||z[1][0]=="X"&&z[1][1]=="X"&&z[1][2]=="X"||z[2][0]=="X"&&z[2][1]=="X"&&z[2][2]=="X"||z[0][0]=="X"&&z[1][0]=="X"&&z[2][0]=="X"||z[0][1]=="X"&&z[1][1]=="X"&&z[2][1]=="X"||z[0][0]=="X"&&z[1][1]=="X"&&z[2][2]=="X"||z[0][2]=="X"&&z[1][1]=="X"&&z[2][0])
{
return true;
}
}
}