Java implementation of a word search solver