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 trialIsam Al-Abbasi
2,058 PointsWhy am I getting this error please?
I'm trying to test out the isEmpty method in the repl by creating new dispenser but I keep getting this error:
java> :load PezDispenser.java loaded source file from PezDispenser.java java> PezDispenser pd = new PezDispenser("Yoda"); java.util.NoSuchElementException java>
Isam Al-Abbasi
2,058 PointsThank you stephen, I don't know why I was getting this error but I played around a little with the code and it worked!!
Tristan Smith
3,171 PointsHi Isam,
Congrats on getting it to work! That kind of "push-through" attitude is great. For the benefit of anyone else having this issue, would you mind sharing what your solution was? :-) (Maybe post some before and after code)
Isam Al-Abbasi
2,058 PointsHello Tristan, unfortunately I don't have the code before and after but all I did is correcting some syntax errors on my code and then it worked!
Stephen Shine
5,991 PointsStephen Shine
5,991 PointsCould you put the code in PezDispenser.java in here so we can have a look?
I'm still learning Java too, but after a quick Google I found the Java doc for this exception: https://docs.oracle.com/javase/7/docs/api/java/util/NoSuchElementException.html
Something to do with Enumeration(?)