Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects (Retired) Harnessing the Power of Objects Helper Methods and Conditionals

Jonathan Ramirez
Jonathan Ramirez
6,284 Points

NoSuchMethodError for .load() and .isEmpty

Hi there,

When trying to run the code in the console, I've written it exactly as instructed in the video.

Can you have a look at my code and see if I've introduced any bugs?

 <p> public class PezDispenser {
  public static final int MAX_PEZ = 12;


  private String mCharacterName;

  private int mPezCount;  


  public PezDispenser (String characterName) {
    mCharacterName = characterName;
    mPezCount = 0;
  }

 public boolean isEmpty() {
  return mPezCount == 0;
 }

  public void load() {
    mPezCount = MAX_PEZ;
  }

  public String getCharacterName() {
    return mCharacterName; </p>
  }
}
Lucas Santos
Lucas Santos
19,315 Points

Why is there a random closing paragraph tag at the end of your getCharacterName function?

1 Answer

Jon Sultana
Jon Sultana
6,916 Points

You also have the opening paragraph tag in the beginning of the code.