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,186 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