java code from cs10