add java solution to problem 4