P174: Added Java solution.