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

Please help! I can't see why the REPL returns these errors

Hey guys! I keep getting this error when I am using the PezDispenser.MAX_PEZ query in REPL. Here it is:

java> :load PezDispenser.java
Loaded source file from PezDispenser.java

java> PezDispenser.MAX_PEZ
ERROR: not a statement
PezDispenser.MAX_PEZ;
^

ERROR: cannot find symbol
symbol: variable PezDispenser
location: class Evaluation
PezDispenser.MAX_PEZ;
^

My constant variable is declared correctly and my member variable as well.

public static final int MAX_PEZ = 12;

private static int mPezCount;

I have also initialized the member variable in the constructor:

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

And I am using it in the load() method to load the Pez:

public static void load() { mPezCount = MAX_PEZ; }

Can someone help me figure out what the error is? Thanks :D

1 Answer

java> :load PezDispenser.java Loaded source file from PezDispenser.java

java> PezDispenser pd = new PezDispenser("Yoda"); PezDispenser pd = PezDispenser@4752ebba

java> pd.MAX_PEZ;
java.lang.Integer res1 = 12