Since you are not writing a high-performance application, it is a bad style to store so much semantics in an index variable.
A better approach would be to use a map.
E. G. Map<Item, Integer> itemStock and Map<Item, Double> prices . You will also not have problems with the delete operation.
source share