\$\begingroup\$

This problem begs for recursion....

private static final void checkWord(char[] chars, char[]current, int len, List<String> results) { if (len == chars.length) { final String result = new String(current); if (sortedDictionary.contains(result)) { results.add(result); } } else { // get the next combination for what is left in the chars for int (i = xx; i < yy; i++) { current[len] = .... // next char to try checkWord(chars, current, len+1 results); } } }

EDIT

This is a 'nice' problem, it ties in all the favourite educational problems, factorial, combinations, and permutations...

Here is working code that runs through the process.... I have commented it where I think necessary. I am doing this so that I have a record on here of what things are, and can refer back to it later, if needed.: