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 Helper Methods and Conditionals

Arturo Galan
Arturo Galan
558 Points

Why can't I create a new dispenser in the java-repl?

When I try to create a new dispenser in the java-repl using the command
PezDispenser pd = new PezDispenser("Yoda"); it gives me an error and the error looks like this ERROR: cannot find symbol symbol: class PezDispenser location: interface Evaluation PezDispenser method$y1r0so3qbxfcwlg4hz6p(); ^ I'm not sure what this means and I've tried searching the internet with no luck. Maybe I have a syntax error somewhere, but I've scrutinized my code for a pretty long time. Please help!!!

Thank you for posting this question I am facing the same problem. This is not just the case with this example but with the previous one too, "PezDispenser.MAX_PEZ;" even this code shows the same error.

THANKS FOR POSTING THIS QUESTION!! AND THANKS IN ADVANCE TO WHOEVER ANSWERS THIS!!

2 Answers

Kourosh Raeen
Kourosh Raeen
23,733 Points

Did you load the java file in repl?

:load PezDispenser.java
Arturo Galan
Arturo Galan
558 Points

Yea but it's still giving me the error

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Try to compile it outside the REPL

javac PezDispenser.java

Do you get any syntax errors?

Actually the problem was with repl. The Treehouse staff Chris Ramacciotti said that in repl the :load command is unable to parse correctly if in the comments there is something called class i. e., //............ class........ then it won't compile. If you run the same code removing all comments the program will run.

There are no syntax errors when compiled as. javac PezDispenser.java