Welcome to the Treehouse Community
Looking to learn something new?
I really don't understand the second line!
PezDispenser dispenser = new PezDispenser();
what is this please explain PezDispenser is the another java file? how was this automatically recognized?
should i worry i don't understand this line?
So the format for the second line is (in my own words): <Declare variable type> <name of variable> = <action>
Declaring the variable type is what we've been doing when making a new string. We would start the line with: String nameOfString = xxxx
In this case, the variable type we are using here is "PezDispenser" which we then name "dispenser."
The action is to create the new class, so "new PezDispenser();"
At this point it's calling on the file PezDispenser.java that we made in order to create the new class PezDispenser.
I know I'm answering this months after the question was asked, but maybe it will help anyone else who found this confusing.
in this line i create an object of type PezDispenser. when u create an object u have access to all his methods.