我正在创建一个新的实例时在这个类上获得NPE:
tolerance
例外情况如下:
public class Kunde {
private IntegerProperty number;
private StringProperty name;
public Kunde(int number, String name) {
setNumber(number);
setName(name);
}
public IntegerProperty getNumber() {
return number;
}
public StringProperty getName() {
return name;
}
public void setNumber(int number) {
this.number.set(number);
}
public void setName(String name) {
this.name.set(name);
}
之前有效,我没有改变任何东西。但没有任何作品
Caused by: java.lang.NullPointerException
at Kunde.setNumber(Kunde.java:23)
at Kunde.<init>(Kunde.java:12)
at LoginController.start(LoginController.java:58)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
我不知道setNumber(int)如何导致这个NPE。
有什么想法吗?提前谢谢!