add java solution to problem 8