Java Java Objects Meet Objects Constructors

Brendan Passey
Brendan Passey
999 Points

At what point to we ask users to pass in a string to our constructor?

He says at about 3.48 that the code public PezDispenser(String characterName) { this.characterName = characterName; } is asking the user to pass in a string arguement but i don't see how. We aren't using Console.readline or any similar method to ask for user input so what does he mean? Is it just seudo code? I've also run the code and it never prompt for input...... please explain?

1 Answer

Andy Stevens
Andy Stevens
8,701 Points

I see the confusion, the name is passed in as an argument when creating the object PezDizpenser i.e. PezDizpenser dispenser = new PezDizpenser(“Yoda”);

I guess Craig is referring to himself as the user.