Writing a Tic Tac Toe program, but the output isn't what it should be, could anyone help?
<p>To explain what I'm doing, I'm basically taking a string of X's and O's as an input String, converting it to an array, so XXXOXOXOO as the input would be the same array. Then I'm checking each possible scenario where one could win, coordinate wise, and if it matches it through if statements it returns the number corresponding to who won.</p>

<p>But it's not quite working, haha. It seems to only output O as the winner, in clear cases where X should win.</p>

<p>Could anyone lend a hand? Much appreciated in advance, thanks.</p>

<pre><code>import java.util.Scanner;
public class TicTacToe {
    public static void main(String[] args) {

        Scanner keyboard = new Scanner(System.in);

        System.out.println("Type in a board for analysis");
        String b = keyboard.nextLine();

        drawBoard(b);

        int result = decide(b);

        if (result == 1) {
            System.out.println("Win for X");
        }
        else if (result == 0) {
            System.out.println("Win for O");
        }
        else if (result == 3)  {
            System.out.println("Draw");
        }
        else {
            System.out.println("Game Unfinished");
        }
   }

    public static int decide(String scheme) {
        int decision = 0;

        String boardScheme[] = new String[9];

        for (int i = 0; i &lt; 9; i++) {
            boardScheme[i] = scheme.substring(i,i+1);
        }

        if ((boardScheme[0] == boardScheme[1] &amp;&amp; boardScheme[0] == boardScheme[2]) || (boardScheme[0] == boardScheme[3] &amp;&amp; boardScheme[0] == boardScheme[6]) || (boardScheme[0] == boardScheme[4] &amp;&amp; boardScheme[0] == boardScheme[8])) {
            if (boardScheme[0] == "X") {
                decision = 1;
            }
            else {
                decision = 0;
            }
        }
        else if (boardScheme[3] == boardScheme[4] &amp;&amp; boardScheme[3] == boardScheme[5]) {
            if (boardScheme[3] == "X") {
                decision = 1;
            }
            else {
                decision = 0;
            }
        }
        else if (boardScheme[6] == boardScheme[7] &amp;&amp; boardScheme[6] == boardScheme[8]) {
            if (boardScheme[6] == "X") {
                decision = 1;
            }
            else {
                decision = 0;
            }
        }
        else if (boardScheme[1] == boardScheme[4] &amp;&amp; boardScheme[1] == boardScheme[7]) {
            if (boardScheme[1] == "X") {
                decision = 1;
            }
            else {
                decision = 0;
            }
        }
        else if ((boardScheme[2] == boardScheme[5] &amp;&amp; boardScheme[2] == boardScheme[8]) || (boardScheme[2] == boardScheme[4] &amp;&amp; boardScheme[2] == boardScheme[6])) {
            if (boardScheme[2] == "X") {
                decision = 1;
            }
            else {
                decision = 0;
            }
        }

        return decision;
    }

    public static void drawBoard(String scheme) {
        if (scheme.length() == 9) {
            String board[] = new String[9];

            for (int i = 0; i &lt; 9; i++) {
                board[i] = scheme.substring(i,i+1);
            }

            System.out.println(board[0] + " | " + board[1] + " | " + board[2]);
            System.out.println(board[3] + " | " + board[4] + " | " + board[5]);
            System.out.println(board[6] + " | " + board[7] + " | " + board[8]);
        }
        else {
            System.out.println("Please input 9 characters, no more, no less.");
        }
    }
}
</code></pre>
