Updated java with Eric's solve code.