1
00:00:00,890 --> 00:00:02,120
Constructors.

2
00:00:02,360 --> 00:00:07,160
The constructors are special methods with special declarations.

3
00:00:08,170 --> 00:00:14,920
So constructor declarations don't state a return type and their name matches the class name.

4
00:00:14,920 --> 00:00:22,270
So for example, here, let's create an constructor of this class, my date and time to my my date and

5
00:00:22,270 --> 00:00:22,540
time.

6
00:00:22,540 --> 00:00:25,720
And this is our constructor and assign it here.

7
00:00:25,750 --> 00:00:26,410
Here.

8
00:00:27,010 --> 00:00:28,180
2019.

9
00:00:29,870 --> 00:00:31,640
Here and let's.

10
00:00:32,470 --> 00:00:33,810
Delete of your code.

11
00:00:33,820 --> 00:00:38,080
Here my data and my data and time clock.

12
00:00:38,110 --> 00:00:38,710
Here.

13
00:00:38,710 --> 00:00:40,450
And print this clock here.

14
00:00:40,450 --> 00:00:48,070
So as you remember, we didn't we won't assign anything on clock and you will see what happens then.

15
00:00:48,880 --> 00:00:54,760
So let's print the our clock here, as you can see here.

16
00:00:55,840 --> 00:00:56,530
So.

17
00:00:58,470 --> 00:01:03,270
Time is here and the or no time.

18
00:01:03,360 --> 00:01:04,230
This is a year.

19
00:01:04,620 --> 00:01:06,180
Year is.

20
00:01:07,910 --> 00:01:14,330
Here and then we will pass clock dot get here method.

21
00:01:14,720 --> 00:01:15,710
So.

22
00:01:17,790 --> 00:01:18,480
Here.

23
00:01:21,150 --> 00:01:28,290
So the new constructor here, as you can see here, the new constructor.

24
00:01:28,530 --> 00:01:38,400
Yeah, the new constructor here takes a single year, takes a single year as a parameter.

25
00:01:38,400 --> 00:01:41,420
So actually, let me write the parameter here.

26
00:01:41,430 --> 00:01:50,700
Integer year in and we will assign this year in or if set year.

27
00:01:51,300 --> 00:01:53,250
Is here in.

28
00:01:54,250 --> 00:01:58,120
Then here equals to 2019.

29
00:01:59,600 --> 00:02:00,290
So.

30
00:02:01,840 --> 00:02:06,760
And as you can see, we need to machine constructor initialization.

31
00:02:06,760 --> 00:02:15,250
So we need to add something add year variable in it because the constructors need a parameter here.

32
00:02:15,250 --> 00:02:16,210
So.

33
00:02:17,240 --> 00:02:18,650
For example, 2020.

34
00:02:19,540 --> 00:02:24,370
Here and we can as you can see, we don't have any errors in the code.

35
00:02:24,370 --> 00:02:30,820
So here takes a single year in argument of type integer here.

36
00:02:30,820 --> 00:02:33,640
So you call the set year.

37
00:02:34,390 --> 00:02:38,380
Here set here with here in.

38
00:02:38,650 --> 00:02:48,250
So if set here returns false the color provided by input and you override here in with a default value

39
00:02:48,250 --> 00:02:50,370
of 2019.

40
00:02:50,380 --> 00:02:59,470
So in main here you make a clock within a new constructor and then print the result.

41
00:03:00,070 --> 00:03:11,320
So the conjugation of the my date and time clock here, 2000 2020 is called an initialization.

42
00:03:12,970 --> 00:03:13,360
Here.

43
00:03:13,780 --> 00:03:23,650
So you might not like the idea that invalid here that in instances where slight silently corrected to

44
00:03:23,680 --> 00:03:26,380
2019, I don't like it either.

45
00:03:26,380 --> 00:03:33,490
So exceptions solve this problem so you will learn about them in next lectures about exceptions here.
