P407: Added Java solution.
P407: Optimized Java solution to calculate solutions iteratively instead of recursively.