Code Challenge Answer in java