Java: 2D char array search
<p>I'm doing a word search program and I think I'm close to figuring it out, but I still have a few problems. My program reads in a text file made up of rows and columns of letters and turns it into a 2d char array into a separate class. This is my actual word search class:</p>

<pre><code>import java.util.Scanner;

public class WordSearch
{
    private char[][] array;
    private String targetWord;
    private int rowLocation;
    private int colLocation;

    public WordSearch(char[][] inArray)
    {
        array = inArray;
    }

    public void play()
    {
        do{
            for (int row = 0; row &lt; array.length; row++)
            {
                for (int col = 0; col &lt; array[row].length; col++)
                {
                    System.out.print(array[row][col]);
                }
                System.out.println();
            }

            System.out.println();
            Scanner input = new Scanner(System.in); 
            System.out.println("What word would you like to search for? Type end to quit: ");
            targetWord = input.nextLine();
            System.out.println("Typed in: " + targetWord);
            System.out.println();

            compareFirst(targetWord);
        } while (!targetWord.equals("end"));

    }

    public void compareFirst(String inWord)
    {
        for (int row = 0; row &lt; array.length; row++)
        {
            for (int col = 0; col &lt; array[row].length; col++)
            {
                if(array[row][col] == inWord.charAt(0))
                {

                    rowLocation = row;
                    colLocation = col;

                    suspectAnalysis();
                }
            }
        }
    }

    public void suspectAnalysis()
    {
        checkRight();
        checkDown();
        checkDiagonal();
    }


    public void checkRight()
    {
        for(int i = 1; i &lt; (targetWord.length()); i++)
        {
            if(colLocation + i &gt; array[0].length - 1)
            {
                return;
            }

            else if(array[rowLocation][colLocation + i] != targetWord.charAt(i))
            {
               return;
            }
        }
        System.out.println(targetWord + " found horizontally at row " + rowLocation + " and column " + colLocation);
        System.out.println();

        return;

    }


    public void checkDown()
    {
        for(int i = 1; i &lt; (targetWord.length()); i++)
        {
            if(rowLocation + i &gt; array.length - 1 &amp;&amp; colLocation + i &gt; array[0].length - 1)
            {
                return;
            }
            else if(array[rowLocation + i][colLocation] != targetWord.charAt(i))
            {
                return;
            }
        }
        System.out.println(targetWord + " found vertically at row " + rowLocation + " and column " + colLocation);
        System.out.println();          
    }

    public void checkDiagonal()
    {
        for(int i = 1; i &lt; (targetWord.length()); i++)
        {
            if(colLocation + i &gt; array[0].length - 1 || rowLocation + i &gt; array.length - 1)
            {
                return;
            }

            else if(array[rowLocation + i][colLocation + i] != targetWord.charAt(i))
            {
                return;
            }
        }
        System.out.println(targetWord + " found diagonally at row " + rowLocation + " and column " + colLocation);
        System.out.println();
    }
}
</code></pre>

<p>So, it usually manages to find words in all three directions, but also "finds" words when it finds the first letter and any other letter after it. It also finds the word "end", which is supposed to terminate the do-while loop, so it just ends up being an infinite loop. Sometimes even if a word can be found both horizontally and vertically, the program only says it's found horizontally. Also, in some cases it prints out where the word was found two times.</p>

<p>Any help figuring out what's wrong would be greatly appreciated. Thanks!</p>