Dynamic Programming - Knapsack solution in Java