0

I wrote a simple program in JAVA having 4 classes:

Main - > CarFaxApp

GUI / Logic - > CarFaxFrame

Object -> Car

Validator -> CarFaxValidator

Once the program is running and I start to enter the necessary data in the textbox's for the car (String vin, String make, String model, int year). Everything works fine, but when I hit buttonADD(), I get a error.

private HashMap<String,Car>hmCar; //Hashmap to hold Cars, the key pair value consists of (Vin, Car Object)

The error happens on hmCar.put(car.getVin(), car); which I dont understand why, I tried debugging up to the point and car does hold the correct values.

Here a screen shot of the error:

enter image description here

Joshua Dalley
  • 339
  • 3
  • 6
  • 23

1 Answers1

2

the error is NullPointException, are you sure you do this hmCar = new HashMap<String, Car>(); before you put the entry in.

Wednesday
  • 74
  • 4