word chain program with java