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
Jav Belson
Courses Plus Student 64 Pointshow dispenzer part work in dispenzer.fill()
i wanna know about in this code
PezDispenser dispenser = new PezDispenser("Yoda");
System.out.printf("The dispenser is %s %n",
dispenser.getCharacterName()
);
public void fill(){
pezCount = MAX_PEZ;
}
//And in this how dispenzer get join to fill part//
system.out.println("delicious pez");
dispenser.fill();
2 Answers
Steve Hunter
57,712 PointsHi there,
Looking at that, it would suggest that each PezDispenser instance has a constant defined at class level called MAX_PEZ. The fill() method sets the instance variable called pezCount to be the value held by the MAX_PEZ constant. So, whatever level the instance has when the fill() method is called, it is filled to the max level in this method.
I hope that makes sense!
Steve.
Jav Belson
Courses Plus Student 64 PointsThank you