-2
我遇到了愚蠢的情況:(,我試圖調用對象的另一種方法,但總是返回空值(我已經添加消氣......)調用對象 - JAVA
可有人想出了我。問題
這裏我的代碼:
private Email email;
public void loadPage() { // Call from init page
email = emailDAO.findById(40); // I debugged here and had values
}
public String changeResetPassword() { // Call by click button event
email.getSender(); // Error here - java.lang.NullPointerException
}
public Email getEmail() {
return email;
}
public void setEmail(Email email) {
this.email = email;
}
您確定您以正確的順序調用'loadPage'和'changeResetPassword',並且在相同的實例上調用嗎? – benzonico