add java solution for problem 7