P14: Simplified Java solution.