Imagine that there is a knapsack with a certain capacity and a number of items with a certain weight and value. Items are represented by the Item class that has two getters, getWeight() and getValue() that return the item's weight and value respectively. Write a method that accepts an array of Item objects and a knapsack's capacity and finds the maximum possible total value of the items you can put in the knapsack.
Check this picture:
The knapsack has the capacity of 5 and there are four available items. We can get the maximum possible value of 7 if we put these two items in the knapsack. Remember that we can put each item only once!