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 Methods and Constants

Martin Turner
Martin Turner
1,757 Points

ERROR: Cannot find symbol (MAX_PEZ)

Hi all,

I'm using the java-repl to follows the steps on the Methods and Constants video; as far as I can see, my code is identical; however, after created the new PezDispenser object as name pd, when I input pd.MAX_PEZ I get the following error message:

ERROR: cannot find symbol
symbol: variable MAX_PEZ
location: variable pd of type PezDispenser
pd.MAX_PEZ;;

Here's my code from the PezDispenser class:

public class PezDispenser {
  public final int MAX_PEX = 12;
  private String mCharacterName;

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

  public String getCharacterName() {
    return mCharacterName; 
  }
}

Many thanks!

Martin Turner
Martin Turner
1,757 Points

Sorry I did notice the obvious MAX_PEX spelling mistake! Though even with this corrected, I am still facing the same error message. Thanks

2 Answers

Could it be the difference between MAX_PEX in your code and MAX_PEZ in your repl?

Steve.

Martin Turner
Martin Turner
1,757 Points

Hi Steve,

Thanks yes I did spot that after, though even with it amended I seem to have the same issue

Martin Turner
Martin Turner
1,757 Points

Actually I reloaded the repo and seems ok now, thanks for your comment!

Martin Turner
Martin Turner
1,757 Points

repl even, clearly spelling isn't my strong point today!! :D

Glad you got it going again!

Steve.