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

philip williams
philip williams
5,991 Points

java-repl error message

treehouse:~/workspac
Welcome to JavaREPL
Type expression to e
java> :load PezDispenser.java
Loaded source file from PezDispenser.java
java> PexDispenser pd = new PezDispenser("Yoda");
ERROR: cannot find symbol
symbol: class PexDispenser
location: interface Evaluation
PexDispenser method$q5o08unelbsk1mpgv9y7();
^
java> PezDispenser pd = new PezDispenser("Yoda");
java.util.NoSuchElementException
java> pd.isEmpty();
ERROR: cannot find symbol
symbol: variable pd
location: class Evaluation
pd.isEmpty();;
^

java>

Can someone please help, i have no idea why i'm getting these error messages. The only thing in think of is i haven't created anything named "pd" so i can't run it if it isn't there. I have scoured the forum for help but my problem doesn't seem to be there.

I think that you have something wrong in your PezDispenser.java code if you would attach your PezDispenser code maybe I could help

3 Answers

Cory Carlson
Cory Carlson
5,275 Points

Phillip, public PezDispenser(String characterName) { mCharacterName = characterName; mPexCount = 0; }

You have typo in "mPexcount"

is should be "mPezCount"

You've done the same thing in repl with "PexDispenser" java> PexDispenser pd = new PezDispenser("Yoda"); ERROR: cannot find symbol

Yes, it seems that you are encounter a syntax error Phillip "mPexCount" should be "mPezCount" thx cory

philip williams
philip williams
5,991 Points

public class PezDispenser { public static final int MAX_PEZ = 12; private String mCharacterName; private int mPezCount;

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

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

public void load() { mPezCount = MAX_PEZ; }

public String getCharacterName(){ return mCharacterName; } }

Hi Nasser, do you need to see Example.java also?

philip williams
philip williams
5,991 Points

thanks guys this really has helped