0

To explain further, I have a class named Website which contains the method checkout() which is as follows:

    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);

I want to call this checkout() method from my Member class, specifically through the method payForHoliday()

The code for this is currently:

    public void payForHoliday(Website website)

    website.checkout(this, holiday);

It works BUT I am given an error in the terminal window which reads:

java.lang.NullPointerException
at Website.checkout(Website.java:79)
at Member.payForHoliday(Member.java:108)

Can anyone give me any help? Thanks.

  • there is not enough code to show us why you are getting this null pointer exception. however the reason is because the object you are using to call the method payForHoliday has not been initialized. – RAZ_Muh_Taz Nov 21 '17 at 18:18
  • What other code do you need to see? And how can I initialise payForHoliday? Im quite new to Java – user8981199 Nov 21 '17 at 18:21

0 Answers0