1
00:00:00,480 --> 00:00:04,590
An inline 20 I decided to output that value to the concert.

2
00:00:04,740 --> 00:00:05,860
So this is that's what DO.

3
00:00:05,930 --> 00:00:07,480
OK number 56.

4
00:00:07,590 --> 00:00:08,610
So what's going on here.

5
00:00:08,610 --> 00:00:13,670
So whenever we actually run our project it's going to actually execute this method here.

6
00:00:13,670 --> 00:00:14,640
This main if it.

7
00:00:14,700 --> 00:00:19,340
So inside of this method we are creating an object from this tiger class card.

8
00:00:19,350 --> 00:00:20,520
My second tiger.

9
00:00:20,520 --> 00:00:21,090
OK.

10
00:00:21,270 --> 00:00:27,690
In Line 14 and it's going to actually execute our constructor OK are constructed inside the target class.

11
00:00:27,750 --> 00:00:28,220
So.

12
00:00:28,260 --> 00:00:30,170
So this is our constructor OK.

13
00:00:30,300 --> 00:00:34,920
And then it's going to actually execute these lines of code inside of these constructor.

14
00:00:34,960 --> 00:00:39,480
OK so this is how it's going to actually execute codes inside of our program.

15
00:00:39,480 --> 00:00:39,910
OK.

16
00:00:40,110 --> 00:00:44,980
So now I want to show you another important point about constructors in Java.

17
00:00:45,360 --> 00:00:51,230
So first let me actually comment out these lines of code here.

18
00:00:54,340 --> 00:00:55,080
OK.

19
00:00:55,420 --> 00:01:00,240
And now I want to actually create multiple constructors for my higher class.

20
00:01:00,250 --> 00:01:00,720
OK.

21
00:01:00,790 --> 00:01:06,490
So as you can see here I created two constructors here and another constructor here.

22
00:01:06,520 --> 00:01:10,210
OK so now I want to actually execute all of these constructors.

23
00:01:10,300 --> 00:01:17,080
So I just need to delete these symbols here in order to allow the compiler to execute these lines of

24
00:01:17,080 --> 00:01:17,590
code here.

25
00:01:17,610 --> 00:01:22,340
OK so now I just need to delete these symbols here and here.

26
00:01:22,420 --> 00:01:23,180
OK.

27
00:01:23,440 --> 00:01:24,450
As you can see here.

28
00:01:24,700 --> 00:01:27,770
Now I have actually three constructors.

29
00:01:27,820 --> 00:01:29,560
So now it's showing us an error.

30
00:01:29,680 --> 00:01:33,060
Let's actually hover over the error area and see what's the error.

31
00:01:34,270 --> 00:01:37,310
Duplicate Somerford tiger type Tiger.

32
00:01:37,450 --> 00:01:42,780
So as you can see here we have two constructors with the same name and with no arguments.

33
00:01:42,840 --> 00:01:45,290
OK so this is not right.

34
00:01:45,310 --> 00:01:53,440
We need to actually create a different constructor and this one in order to allow the compiler to execute

35
00:01:53,440 --> 00:01:54,600
these lines of code here.

36
00:01:54,610 --> 00:01:55,040
OK.

37
00:01:55,120 --> 00:02:02,150
We cannot create duplicate constructivists with the same name and with the same argument type.

38
00:02:02,290 --> 00:02:08,650
So here I want to specify that this constructor is going to accept an argument data type of my argument

39
00:02:08,680 --> 00:02:12,680
is it and the name of my argument is not a.

40
00:02:13,180 --> 00:02:13,840
OK.

41
00:02:14,230 --> 00:02:19,270
And then I want to add this number here to the value of my argument.

42
00:02:19,270 --> 00:02:22,390
OK so 56 plus number a.

43
00:02:22,800 --> 00:02:23,680
OK.

44
00:02:24,010 --> 00:02:28,840
And now as you can see we've got three different constructors inside the tiger class.

45
00:02:28,850 --> 00:02:36,820
OK so this is our first constructor and this is our default constructor and this is our second constructor.

46
00:02:36,970 --> 00:02:45,340
This constructor accepts two arguments so that we can actually pass two values to the constructor and

47
00:02:45,520 --> 00:02:48,130
the first constructor is this constructor.

48
00:02:48,130 --> 00:02:55,930
This constructor accepts one argument and then here in line 19 you are actually adding this number here

49
00:02:55,930 --> 00:02:59,560
56 to the value of the argument here not a.

50
00:02:59,710 --> 00:03:05,650
And then we are actually assigning the result of this operation here to our speed instance valuable

51
00:03:06,220 --> 00:03:10,720
and in line 20 you are actually outputting that value to the console OK.

52
00:03:10,990 --> 00:03:16,980
So inside the main class now as you can see here I want to actually run my project and see what happens.

53
00:03:16,990 --> 00:03:22,940
So if I run my project now as you can see this is the value that is output to the console.

54
00:03:23,110 --> 00:03:25,590
This is our default constructor OK.

55
00:03:25,930 --> 00:03:32,400
So what's going on here as you can see here we didn't actually pass any values to the constructor here.

56
00:03:32,410 --> 00:03:33,460
OK.

57
00:03:33,530 --> 00:03:40,210
Now in line 14 inside the main class and inside the main Mefford we are actually creating an object

58
00:03:40,240 --> 00:03:44,370
from this tiger class and the name of our object is my second tiger.

59
00:03:44,380 --> 00:03:44,790
OK.

60
00:03:44,790 --> 00:03:48,410
Of an approach AirTrans first is going to actually execute this main method.

61
00:03:48,430 --> 00:03:48,980
Okay.

62
00:03:49,240 --> 00:03:54,800
And then as you can see here in say the main If it is going to actually execute this line of code here.

63
00:03:54,970 --> 00:04:00,100
Here we are actually trained to create an object from this tiger class.

64
00:04:00,100 --> 00:04:07,820
So as you can see here it's going to actually execute the default constructor for our tiger class.

65
00:04:07,840 --> 00:04:08,230
OK.

66
00:04:08,230 --> 00:04:11,850
So inside the tile class this is our default constructor.

67
00:04:11,860 --> 00:04:12,310
OK.

68
00:04:12,340 --> 00:04:13,500
As you can see here.

69
00:04:13,630 --> 00:04:15,880
This constructor accepts no argument.

70
00:04:15,880 --> 00:04:22,150
So this is called the default constructor and then inside the constructor I decided to output some values

71
00:04:22,150 --> 00:04:25,920
to the console and that value is this value here as a currency.

72
00:04:25,990 --> 00:04:31,660
And now I want to actually pass two values to my constructor here.

73
00:04:31,900 --> 00:04:37,820
So here I can actually put number three comma number 7 for example.

74
00:04:38,140 --> 00:04:41,020
And as you can see here if I use on my project.

75
00:04:41,020 --> 00:04:43,050
Now let's see what happens.

76
00:04:43,060 --> 00:04:46,330
As you can see it's going to actually output this value to the console.

77
00:04:46,600 --> 00:04:51,520
So this value is the result of execution of this constructor here.

78
00:04:51,670 --> 00:04:52,590
OK.

79
00:04:53,140 --> 00:05:00,700
When we actually create an object from the tile class it's going to execute the constructor that we

80
00:05:00,700 --> 00:05:02,760
created inside the target class here.

81
00:05:02,860 --> 00:05:08,830
OK this is our constructor and this constructor accepts two arguments with the data type.

82
00:05:08,830 --> 00:05:14,740
OK so we passed two numbers as against the two integer numbers through this constructor number three

83
00:05:14,740 --> 00:05:16,380
and number seven.

84
00:05:16,480 --> 00:05:21,070
And then it's going to go inside the constructor and then it's going to actually execute these lines

85
00:05:21,070 --> 00:05:22,040
of code here.

86
00:05:22,150 --> 00:05:28,900
First we created a variable called result and then we tried to actually add the value of these two arguments

87
00:05:28,900 --> 00:05:34,180
together and then be assigned that value to the result variable.

88
00:05:34,360 --> 00:05:38,530
And that in line 14 we decided to output that value to the console.

89
00:05:38,690 --> 00:05:42,450
Number three plus number seven is number 10.

90
00:05:42,630 --> 00:05:43,380
Okay.

91
00:05:43,810 --> 00:05:49,990
And now as you can see our first constructor accepts one argument as you can see here.

92
00:05:49,990 --> 00:05:53,210
So let's actually pass only one value here.

93
00:05:53,310 --> 00:05:55,550
And let's run our project again.

94
00:05:55,570 --> 00:06:00,210
So as you can see here it's going to output this value to the console number 59.

95
00:06:00,400 --> 00:06:06,130
So as you can see here I passed a number of free to this constructor and then it can actually execute

96
00:06:06,580 --> 00:06:07,920
this constructor here.

97
00:06:08,070 --> 00:06:12,630
OK this constructor accepts only one argument with the data type.

98
00:06:12,640 --> 00:06:17,950
So I passed number three which is an integer number two this constructor here.

99
00:06:18,100 --> 00:06:23,410
And then it's going to go inside of this constructor and that it's going to execute these lines of code

100
00:06:23,410 --> 00:06:24,940
here in line 19.

101
00:06:24,970 --> 00:06:31,580
We tried to actually add number 56 to the value of the number a argument.

102
00:06:31,690 --> 00:06:35,940
So the value of the non argument is free as you can see here.

103
00:06:35,940 --> 00:06:44,940
So 56 plus free is 59 and then it's going to assign that value to this instance variable and then it's

104
00:06:44,940 --> 00:06:47,220
going to actually output that value to the concert.

105
00:06:47,340 --> 00:06:50,580
So this value is the value of this instance of it.

106
00:06:50,820 --> 00:06:57,120
And inside the main class if you want to actually access the value of this instance variable and output

107
00:06:57,210 --> 00:07:05,390
that that's value to the console I'll just type in here system that out at Princeton and then inside

108
00:07:05,390 --> 00:07:08,440
the prentices I can't just refer to the name of my object.

109
00:07:08,470 --> 00:07:14,890
My second Tiger does get speed and then I need to put in a semi-colon at the end of my statement.

110
00:07:15,040 --> 00:07:20,390
So now if I run on my project has again satisfied you again is output to the console OK.

111
00:07:20,410 --> 00:07:23,850
This value is the value of the spit instance variable of DS.

112
00:07:23,920 --> 00:07:25,450
My second Tigard object.

113
00:07:25,480 --> 00:07:26,140
OK.

114
00:07:26,350 --> 00:07:32,590
So now if I want to actually create another object from the tiger class here as you can see I just need

115
00:07:32,590 --> 00:07:41,020
to refer to the name of my class tiger and the name of my object is my first object my first tiger.

116
00:07:41,430 --> 00:07:42,180
OK.

117
00:07:42,250 --> 00:07:48,580
And then I need to put in an assignment operator here and then I need to put in this new word and then

118
00:07:48,610 --> 00:07:52,220
again I need to refer to the name of my class here.

119
00:07:52,330 --> 00:07:58,270
So here I actually use the autocomplete feature of the eclipse by pressing on the control key plus the

120
00:07:58,570 --> 00:08:00,310
space key on my keyboard.

121
00:08:00,400 --> 00:08:03,520
As you can see it's going actually comment as these are free options.

122
00:08:03,520 --> 00:08:06,370
The first one is the constructor.

123
00:08:06,370 --> 00:08:08,170
Without no argument.

124
00:08:08,170 --> 00:08:15,310
The second is a constructor with one argument and the first one is constructed with two arguments.

125
00:08:15,340 --> 00:08:18,840
OK we can actually choose between these free arguments.

126
00:08:18,840 --> 00:08:23,740
For example if I choose this one now I need to actually passing two values.

127
00:08:23,740 --> 00:08:25,390
For example number three.

128
00:08:25,810 --> 00:08:27,010
And number two.

129
00:08:27,220 --> 00:08:30,370
And then I need to put in a semi-colon at the end of my statement.

130
00:08:30,580 --> 00:08:35,620
And now if I on my project as you can see this value is out with the console number 5.

131
00:08:35,620 --> 00:08:38,030
So number three plus number two is five.

132
00:08:38,250 --> 00:08:38,530
OK.

133
00:08:38,530 --> 00:08:42,250
As you can see here this constructor accepts two arguments.

134
00:08:42,280 --> 00:08:49,860
And here we are actually adding the value of the first argument to the value of the second argument.

135
00:08:49,870 --> 00:08:52,120
And we are actually out with that's why they go to the concert.

136
00:08:52,120 --> 00:08:55,570
So this value is the result of execution of this constructor here.

137
00:08:55,570 --> 00:08:56,110
OK.

138
00:08:56,170 --> 00:09:00,870
I can't even actually pass one value to this constructor for example number two.

139
00:09:00,890 --> 00:09:05,510
And if I run my project now as you can see it's going to output this value to the console.

140
00:09:05,620 --> 00:09:09,790
So this value is the result of execution of this constructor here.

141
00:09:10,060 --> 00:09:16,560
As you can see here number 56 plus number 2 is number 58 as you can see here.

142
00:09:16,570 --> 00:09:17,180
OK.

143
00:09:17,470 --> 00:09:23,800
And I can even actually pass no values to the constructor and if I get on my project as you can see

144
00:09:23,800 --> 00:09:25,810
it's going out with this value to the console.

145
00:09:25,960 --> 00:09:27,460
This is a default constructor.

146
00:09:27,460 --> 00:09:27,970
OK.

147
00:09:28,030 --> 00:09:35,230
So hopefully that makes sense and I think that's enough for constructor's in this tutorial and in the

148
00:09:35,230 --> 00:09:36,670
other sections of this course.

149
00:09:36,700 --> 00:09:41,440
I'll talk more about constructor's in terms of other important concepts of d'Artois.

150
00:09:41,440 --> 00:09:42,040
OK.

151
00:09:42,220 --> 00:09:43,710
So for now it's enough.

152
00:09:44,030 --> 00:09:49,430
And if you have any questions about these constructivists please post the discussion in the course.

153
00:09:49,690 --> 00:09:53,980
And thanks very much for watching and I'll see you in the next tutorial.

