Java version of Chain Reaction program