add java solution to problem 3