import java.awt.*; public class WordSearch7 { public static void main (String[] argv) { char[][] puzzle = { {'n', 'o', 'h', 't', 'y', 'p', 's'}, {'m', 'i', 'a', 'r', 'y', 'c', 'c'}, {'l', 'l', 'e', 'k', 's', 'a', 'h'}, {'r', 'u', 'b', 'y', 'v', 'm', 'e'}, {'e', 'h', 'h', 'a', 'l', 'l', 'm'}, {'p', 'c', 'j', 'n', 'i', 'c', 'e'}, {'r', 'e', 'e', 'k', 'b', 'i', 'p'} }; Point p = findWord (puzzle, "ruby"); if (p == null) { System.out.println ("Not found"); } else { System.out.println ("Found in row " + p.x + " column " + p.y); } } static Point findWord (char[][] puzzle, String word) { // First convert the String into a char array. char[] letters = word.toCharArray (); // Now try every possible starting point in the puzzle array. for (int i=0; i= puzzle[i].length) || (letters[k] != puzzle[i][j+k]) ) { // Not a match. found = false; break; } } // If we went the whole length of the word, we found it. if (found) { return new Point(i,j); } } } return null; } }