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!
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
Jacob Klug469 Points
Why did we do add (String characterName) to public PezDispenser? What does adding that do?
What did ( String characterName) after public Dispenser do for our code?
Alex Bratkovskij5,329 Points
Because it is a constructor.
"A constructor is a method that will run when you instantiate the class. Again instantiation happens when you create the new instance of the class using the new keyword. A constructor is a great place to stick required information about the initial set up of the object."
Additionally, this might be usefull: https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html