Java Java Objects Harnessing the Power of Objects Exceptions

Antonio Foresta
Antonio Foresta
931 Points

I'm not sure what the role of this method in this class is

I understood that the role of this is crucial for the whole thing working but I'm not sure why .

public void fill(){ fill(MAX_PEZ); }

2 Answers

This is an overload for the other fill(int pezAmount) method. This method takes an integer argument for how many pez to load. But if you call the fill method without a parameter, it is redirected to call the fill method with the MAX_PEZ number as the parameter. If you look at the code for the fill(int pezAmount) method, I think it will make more sense. Hope this helps!