Constructors.
The constructors are special methods with special declarations.
So construction declarations don't state a return type and their name matches the class name.
So, for example, here, let's create an constructor of this class, my date and time to my date and
time.
And this is our constructor and assign it to year here.
2019.
Here and let's.
The letter here, quote Here my date and my date and time clock here and print this clock here.
So as you remember, we didn't we won't assign anything on clock and you will see what happens then.
So let's print the hour clock here, as you can see here.
So.
Time is here.
And the time.
This is the year.
The year is.
Here and then we will pass clock dot get here method.
So.
Here.
So the new constructor here, as you can see here, the new constructors.
Yeah.
Then the new constructor here takes a single year, takes a single year as a parameter.
So actually let me write the parameter here.
Integer year in and we will assign this year in or if set year.
Is year in.
Then here it comes to 2019.
So.
And as you can see, we need to match infrastructure initialization.
So we need to add something, add a year variable because the constructors need a parameter here.
So.
For example, 2020.
Here.
And we can as you can see, we don't have any errors in the code.
So here takes a single year in argument of type integer here.
So you call the set year.
Here's Seth here with year in.
So if Seth here returns false the caller provided bad input and you override year end with a default
value of 2019.
So in main here you make a clock within the new constructor and then print the result.
So the continuation of the my date and time clock year 2020 20 is called an initialization.
Beer.
So you might not like the idea that.
Invalid year that in instances where slide silently corrected to 2019.
I don't like it either.
So exceptions solve this problem.
So you will learn about them in next lectures about exceptions here.