为了进一步解释,我有一个名为Website的类,其中包含checkout()方法,如下所示:
public void checkout(Member member, Holiday holiday)
System.out.println("Transaction successfully complete.");
System.out.println("Member " + member.getMembershipNumber() + " has paid for " + holiday.getRefNo() + ".");
member.setLoginStatus(false);
我想从我的Member类调用这个checkout()方法,特别是通过方法payForHoliday()
目前的代码是:
public void payForHoliday(Website website)
website.checkout(this, holiday);
它工作但是我在终端窗口中给出了一个错误:
java.lang.NullPointerException
at Website.checkout(Website.java:79)
at Member.payForHoliday(Member.java:108)
任何人都可以给我任何帮助吗? 谢谢。