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 Harnessing the Power of Objects Filling the Dispenser

benjamin wong
benjamin wong
498 Points

cannot find symbol for PezDispenser and MAX_PEZ from PezDispenser.java to Example.java

treehouse:~/workspace$ javac Example.java && java Example
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Example.java:7: error: cannot find symbol
System.out.printf("FUN FACT: There are %d PEZ allowed in every dispenser %n", PezDis penser, MAX_PEZ);
^
symbol: variable PezDispenser
location: class Example
Example.java:7: error: cannot find symbol
System.out.printf("FUN FACT: There are %d PEZ allowed in every dispenser %n", PezDis penser, MAX_PEZ);

    ^                                                                               

symbol: variable MAX_PEZ
location: class Example
2 errors

1 Answer

Yanuar Prakoso
Yanuar Prakoso
15,196 Points

Hi Benjamin Since I cannot see your entire actual code I have to take a guess here. You want to write there are a (maximum number) of PEZ allowed in every dispenser.

If that so, I think you do not need to put PezDis penser... and by the way I think it should be PezDispenser... As you can see inside the printf you only have one %d which represent one integer value in this case and you put two variable in the end.... And moreover, if I am not mistaken PezDispenser is a class not an integer variable. Thus the compiler having a hard time finding PezDispenser as integer variable or in this case constant since it all written in CAPS.

if MAX_PEZ is already declared as int before in your code. You only need to write:

System.out.printf("FUN FACT: There are %d PEZ allowed in every dispenser %n", MAX_PEZ);

I am sorry since I cannot see your actual code this is the best I can help you with by seeing your error log. I hope this can help you a little