add java solution to problem 9