add java solution to problem 18