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

Exceptions in java. when i have written the code my out pout is different from craigs. the chomps are not printing .

Fun fact: There are 12 PEz allowed in every dispenserThe dispenser is Turtle
Dispenser is empty
Filling the dispenser with delicious PEZ..
Exception in thread "main" java.lang.IllegalArgumentException: Too many Pez
at PezDispenser.fill(PezDispenser.java:34)
at PezDispenser.fill(PezDispenser.java:15)
at Example.main(Example.java:21)

saykin
saykin
9,835 Points

From the Exception you provided, it seems you might be overfilling the dispenser.

However without seeing your code, I can't be 100% sure of that. I would recheck your code and make sure you don't fill more than the MAX_PEZ (Can't remember what the variable is called).

1 Answer

Gabriel Murut
Gabriel Murut
5,418 Points

Could you send the code to check it? Probably is what Saykin is commenting.