P417: Added Java solution.