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
Sophie Tarpey
1,066 PointsCannot find symbol error in PezDispenser java objects tutorial
I've done and redone the code for the java objects video but I can not seem to figure out what I need to change. I feel like I have it exactly as the video does but I realize I must have something wrong since I keep getting the error:
ERROR: cannot find symbol
symbol: class PezDispenser
location: interface Evaluation
PezDispenser method$ezdnjwcf4ikrpvo5298a();
^
I've tried looking it up and I can not seem to find what is wrong with it or how to fix it. If someone has experienced this, knows what is wrong with it, and can help me solve my problem that would be great!
Sophie Tarpey
1,066 PointsHere is the link to the workspace: https://w.trhou.se/r5qi8cjc9d
Sophie Tarpey
1,066 Pointsok thanks for the help!
1 Answer
Jennifer Nordell
Treehouse TeacherOk this is truly odd. When I fork the workspace and compile and run the code... this is the output.
We are making a new Pez Dispenser.
The dispenser character is Yoda
I get no compilation errors or warnings and it seems to run as expected. My best advice is to click on the link you posted here and fork the workspace (ie make a copy of it) and then try to compile and run it from the new copy of the workspace.
Sophie Tarpey
1,066 PointsThe part I'm having trouble on is when I'm in Java-repl and I do PezDispenser pd = new PezDispenser. That is when the error is coming up
Jennifer Nordell
Treehouse TeacherFirst, you're supposed to be passing in a name for the character, but that shouldn't be producing the error you're getting. Are you getting an error when you load the PezDispenser.java file?
:load PezDispenser.java
Does the above line generate an error for you?
Sophie Tarpey
1,066 PointsYes it works when I load the PezDispenser.java file
Sophie Tarpey
1,066 PointsAlso sorry I had been putting the name in I just forgot to in the comment. Now when I'm entering PezDispenser pd = new PezDispenser "Yoda"; this error is coming up:
ERROR: '(' or '[' expected
new PezDispenser "Yoda";;
^
I haven't seen this one before and i don't know how to fix it either
Jennifer Nordell
Treehouse TeacherYou should be entering:
PezDispenser pd = new PezDispenser("Yoda");
Note the parentheses around Yoda.
Sophie Tarpey
1,066 PointsWhen I do that I get the cannot find symbol error:
ERROR: cannot find symbol
symbol: class PezDIspenser
location: class Evaluation
new PezDIspenser ("Yoda");;
^
Jennifer Nordell
Treehouse TeacherI honestly don't know. The commands work for me in the REPL. And I'm using your code. My best suggestion is to post a new question, and I'll not put any answers or comments there so you can get a fresh set of eyes on this. I just don't understand why it works for me but not you when we're using the same code. Sorry.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherMy gut instinct is to say that somewhere you've managed to misspell PezDispenser. But, it'd be helpful if we could see a snapshot of your workspace and take a look at your code and file structures. You can achieve this by clicking the camera icon at the upper right of your workspace. Open the link and then copy/paste the URL here. We'll be in a much better position to help you then :)