Reputation: 2072
I have a class called Sell which has a SimpleObjectProperty. In the POJO, the getters and setters are the following:
private ObjectProperty<LocalDateTime> sellDate;
....
public LocalDateTime getSellDate() {
return sellDate.get();
}
public void setSellDate(LocalDateTime value) {
sellDate.set(value);
}
When creating a new instance of the Sell class, I use the method setSellDate()
:
....
Sell sell = new Sell();
//another gets and sets...
sell.setSellDate(LocalDateTime.now());
This line of code is giving me a NullPointerException. What am I doing wrong?
Upvotes: 0
Views: 234
Reputation: 209418
Since sell
clearly isn't null, sellDate
must be the reference that is null. You show where you declare it with
private ObjectProperty<LocalDateTime> sellDate;
but you don't show any code that initializes it. You need something like
sellDate = new SimpleObjectProperty<>();
in the constructor.
Upvotes: 1