P172: Added Java solution.