This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I am getting the following error that I can not figure out, or do not have any idea where to begin. It compiles, but when I go to run it, I get this:
Exception in thread "main" java.lang.NullPointerException at Inventory.value(Inventory.java:28)
When you create your Inventory instance, its products array contains all null values. In the add method you increase numCar, but in several of the loops you are looping over all elements, not just until numCars. As such, you will encounter null for those elements not yet assigned.
Either loop to numCars (exclusively), or use a List<Car> instead.
I apologize for wasting your time. I found what I did wrong, and it had nothing to do with the errors I spoke of above. The problem was in the other classes, and after sleeping on it, I immediately saw what I did wrong.