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

Error making a new PezDispenser in java

I am using the java objects tutorial and have been having a problem when I try to enter PezDispenser pd = new PezDispenser("Yoda"); in the repl. This is the error that is coming up: java.util.NoSuchElementException

This is the link to my workspace: https://w.trhou.se/p05dy8o2xx

If someone could help that would be greatly appreciated!

I have heard of similar problems in workspaces from other people. Did you remember to :load your java classes to java repl?

Yes I loaded it first

Then maybe try and close and reload your workspace.

Did you save and compile the PezDispenser class? (javac PezDispenser.java)

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Sophie Tarpey !

I forked your workspace, and compiled PezDispenser.java. It looks like you are missing a semi-colon in your constructor, so it can't load in the REPL at the moment.

Hope that helps!