1
00:00:00,480 --> 00:00:05,160
Hi everyone in this theater real I'm going to touch about objects in Java.

2
00:00:05,160 --> 00:00:05,780
OK.

3
00:00:06,000 --> 00:00:13,180
So first of all we need to create a project so click on find new and then click on Java project.

4
00:00:13,200 --> 00:00:14,410
OK.

5
00:00:15,180 --> 00:00:20,620
And for the project name just type in here objects and click unfinished.

6
00:00:21,000 --> 00:00:23,910
So as you can see here our project is now created.

7
00:00:24,030 --> 00:00:26,530
So we need a class for our project.

8
00:00:26,580 --> 00:00:33,270
So just click on this as our See folder or you can click on these objects project click on File New

9
00:00:33,360 --> 00:00:34,490
and then click on a class.

10
00:00:34,500 --> 00:00:35,750
OK.

11
00:00:36,030 --> 00:00:41,670
So remember that for every project that you create in Java you'll need a main class.

12
00:00:41,670 --> 00:00:46,900
OK so now we want to actually create a main class for our project.

13
00:00:47,080 --> 00:00:54,960
Just type in here Main and for the package name just type in our reverse domain here come that your

14
00:00:54,960 --> 00:00:59,270
name dot project name objects.

15
00:00:59,780 --> 00:01:00,580
OK.

16
00:01:00,900 --> 00:01:03,340
And for the modifiers choose public.

17
00:01:03,540 --> 00:01:08,870
And here make sure that you check this check box here that says public static void main method.

18
00:01:08,890 --> 00:01:09,340
OK.

19
00:01:09,510 --> 00:01:13,920
This is going to be the starting point for actually running our Java code.

20
00:01:13,950 --> 00:01:14,430
OK.

21
00:01:14,490 --> 00:01:18,130
Otherwise our coats won't be executed at all.

22
00:01:18,240 --> 00:01:23,610
OK so this method is very important but because this class that we are actually creating now is the

23
00:01:23,610 --> 00:01:25,640
main class of our project.

24
00:01:25,800 --> 00:01:28,910
This method is required for this class.

25
00:01:28,920 --> 00:01:29,810
OK.

26
00:01:29,940 --> 00:01:31,450
So just click on finish.

27
00:01:32,130 --> 00:01:36,680
And as you can see here our class is now created and this is our main method.

28
00:01:36,690 --> 00:01:37,380
Okay.

29
00:01:37,840 --> 00:01:40,260
And here let me actually delete this comment here.

30
00:01:40,410 --> 00:01:46,690
And in order to make this editor area a much wider DoubleClick undismayed that you have here.

31
00:01:46,890 --> 00:01:51,270
So as you can see here are a little area is now much wider.

32
00:01:51,270 --> 00:01:55,370
So as I said earlier in this tutorial I want to talk about objects.

33
00:01:55,500 --> 00:01:57,340
OK so what are objects.

34
00:01:57,390 --> 00:02:03,000
First of all let me point out that Java is an object oriented programming language.

35
00:02:03,030 --> 00:02:05,690
OK so what is an object.

36
00:02:05,760 --> 00:02:09,430
What do you see when you look at the world around you.

37
00:02:09,660 --> 00:02:12,590
You see objects right in Java.

38
00:02:12,900 --> 00:02:15,190
We've got the same objects too.

39
00:02:15,420 --> 00:02:18,750
So so what is the definition of an object.

40
00:02:18,750 --> 00:02:22,610
Objects are a representation of things.

41
00:02:22,920 --> 00:02:25,300
Let's look at the world around us.

42
00:02:25,350 --> 00:02:27,120
You see objects everywhere.

43
00:02:27,330 --> 00:02:29,810
For example animals are objects.

44
00:02:29,820 --> 00:02:30,630
OK.

45
00:02:30,790 --> 00:02:34,910
A lion is an object a person is an object.

46
00:02:34,980 --> 00:02:36,740
A pen is an object.

47
00:02:36,780 --> 00:02:40,120
OK your desk is an object.

48
00:02:40,260 --> 00:02:42,480
And lots of other examples.

49
00:02:42,480 --> 00:02:50,040
So when you for example look at a lion you can write a tell me the characteristics and behaviors of

50
00:02:50,040 --> 00:02:50,680
this lion.

51
00:02:50,700 --> 00:02:51,430
OK.

52
00:02:51,600 --> 00:02:56,540
For example the characteristics of a lion are a lion has powerful legs.

53
00:02:56,550 --> 00:02:56,960
OK.

54
00:02:56,970 --> 00:03:01,220
The second characteristic is a lion has a strong jaw.

55
00:03:01,350 --> 00:03:04,290
The first characteristic is a lion is brave.

56
00:03:04,400 --> 00:03:07,910
OK so now let's talk about the behaviors of a lion.

57
00:03:08,100 --> 00:03:08,590
OK.

58
00:03:08,610 --> 00:03:17,370
For example the behaviors of a lion are a lion spends much of his time resting and is in active for

59
00:03:17,370 --> 00:03:19,230
about 20 hours per day.

60
00:03:19,350 --> 00:03:19,900
OK.

61
00:03:19,920 --> 00:03:26,370
That such behavior is an attempt to catch the victim with a fast rush.

62
00:03:26,400 --> 00:03:33,570
The first behavior is a lawyer and takes advantage of the factors that reduce visibility OK.

63
00:03:33,810 --> 00:03:37,060
So how we can relate this example to Java.

64
00:03:37,260 --> 00:03:40,520
So first we need to create a Java class called the law.

65
00:03:40,530 --> 00:03:40,950
OK.

66
00:03:40,980 --> 00:03:43,380
So now let's actually create a Java class.

67
00:03:43,920 --> 00:03:45,910
So click on this package here.

68
00:03:46,200 --> 00:03:46,790
OK.

69
00:03:47,070 --> 00:03:50,900
And then click on find new and then click on class.

70
00:03:50,930 --> 00:03:56,370
So for the name of the class just type in here Lorient with the capital L..

71
00:03:56,630 --> 00:03:57,150
OK.

72
00:03:57,240 --> 00:04:03,330
And here for the package as you can see it's going to put this class inside this package.

73
00:04:03,330 --> 00:04:03,900
OK.

74
00:04:04,080 --> 00:04:09,960
So that's why I actually clicked on this package and then I started to create a class.

75
00:04:09,990 --> 00:04:10,320
OK.

76
00:04:10,320 --> 00:04:11,580
So this is really important.

77
00:04:11,700 --> 00:04:14,300
So this class is going to be inside this package.

78
00:04:14,310 --> 00:04:15,090
OK.

79
00:04:15,510 --> 00:04:19,110
And for the modifiers to publish and then click Finish.

80
00:04:19,110 --> 00:04:22,780
Our class is now created the name of our class is a lion.

81
00:04:22,820 --> 00:04:25,170
OK so what is the class.

82
00:04:25,380 --> 00:04:30,450
As I said earlier our class is a blueprint for creating objects.

83
00:04:30,450 --> 00:04:31,040
OK.

84
00:04:31,230 --> 00:04:34,700
Without a blueprint you cannot create an object.

85
00:04:34,860 --> 00:04:38,200
So suppose that you want to create a car.

86
00:04:38,430 --> 00:04:42,360
What would be the first step in order to actually create a car.

87
00:04:42,510 --> 00:04:47,740
First of all you need a blueprint that shows you exactly how you can create a car.

88
00:04:47,970 --> 00:04:48,540
OK.

89
00:04:48,630 --> 00:04:54,900
So for example this is a blueprint for creating a car or create this blueprint is going to actually

90
00:04:54,900 --> 00:04:57,860
show me exactly how I can create a car.

91
00:04:57,930 --> 00:04:58,470
OK.

92
00:04:58,590 --> 00:05:04,520
So in Java programming reach the blueprint is the class that we create in our projects.

93
00:05:04,530 --> 00:05:04,950
OK.

94
00:05:04,980 --> 00:05:11,870
For example this class is going to be our blueprint in order to show us exactly how I can create life

95
00:05:11,870 --> 00:05:13,000
and objects.

96
00:05:13,020 --> 00:05:13,590
OK.

97
00:05:13,710 --> 00:05:18,730
So as you can see here there are no instructions inside this class.

98
00:05:18,750 --> 00:05:24,870
So now I want to actually put some instructions inside this class in order to show me how I can create

99
00:05:24,940 --> 00:05:26,130
loyal objects.

100
00:05:26,130 --> 00:05:29,970
OK so now let's go back to our car example.

101
00:05:30,090 --> 00:05:35,570
First of all you need a blueprint in order to show you exactly how you can create a car.

102
00:05:35,700 --> 00:05:36,290
OK.

103
00:05:36,420 --> 00:05:40,670
So a car has some characteristics and behaviors.

104
00:05:40,800 --> 00:05:43,170
So what are the characteristics of a car.

105
00:05:43,380 --> 00:05:43,970
OK.

106
00:05:44,130 --> 00:05:49,170
The characteristics of a car are first of all a car has four wheels.

107
00:05:49,170 --> 00:05:57,930
Second of all a car has the braking system and Firstly a car has a steering system OK and a car has

108
00:05:58,020 --> 00:05:59,680
some behaviors too.

109
00:05:59,850 --> 00:06:02,150
So what are the behaviors of a car.

110
00:06:02,280 --> 00:06:04,510
Firstly a car can move.

111
00:06:04,710 --> 00:06:07,100
And secondly a car can break.

112
00:06:07,260 --> 00:06:13,210
OK so now let's go back to our code because I want to show you how you can create objects out of classes.

113
00:06:13,230 --> 00:06:13,560
OK.

114
00:06:13,590 --> 00:06:17,160
So now I want to give some characteristics to my life and class.

115
00:06:17,160 --> 00:06:17,780
OK.

116
00:06:18,000 --> 00:06:21,610
So first of all a lion can run very fast.

117
00:06:21,660 --> 00:06:27,220
So now you want to actually create a variable in order to store the amount of speed that allow you and

118
00:06:27,250 --> 00:06:28,540
can run OK.

119
00:06:29,010 --> 00:06:29,740
OK.

120
00:06:30,120 --> 00:06:36,450
The name of my variable is speed and that I can assign a value to my variable for example 100.

121
00:06:36,590 --> 00:06:37,310
OK.

122
00:06:37,350 --> 00:06:40,970
And then at the end of my statement I need to put in a semicolon.

123
00:06:41,070 --> 00:06:48,150
So as you can see here this variable here is the characteristic of my line class.

124
00:06:48,250 --> 00:06:56,070
Ok this argument here is going to show us what would be the amount of speed of our and objects.

125
00:06:56,070 --> 00:07:01,510
OK so now I want to actually create an object from this class.

126
00:07:01,530 --> 00:07:03,260
So how can I do that.

127
00:07:03,270 --> 00:07:07,770
So first of all let me point out that always save your classes.

128
00:07:07,890 --> 00:07:15,480
So if you are using too match or six just press on comment keep Plus the s key on your keyboard in order

129
00:07:15,480 --> 00:07:16,570
to save your class.

130
00:07:16,740 --> 00:07:23,820
But if you are using a Windows machine press on control key plus the key on your keyboard in order to

131
00:07:23,820 --> 00:07:24,560
save your class.

132
00:07:24,570 --> 00:07:25,200
OK.

133
00:07:25,500 --> 00:07:31,140
So as you can see here there is a Lego Star here beside my class name.

134
00:07:31,170 --> 00:07:31,750
OK.

135
00:07:32,010 --> 00:07:37,800
So now if I actually save my project as you can see that little star is now gone.

136
00:07:37,910 --> 00:07:38,450
OK.

137
00:07:38,550 --> 00:07:42,680
This means that my class is now successfully saved.

138
00:07:42,690 --> 00:07:43,430
OK.

139
00:07:43,830 --> 00:07:50,220
So go back inside the main class and here you want to create an object from the slide in class.

140
00:07:50,230 --> 00:07:52,090
Or you want to create a like an object.

141
00:07:52,110 --> 00:07:52,590
OK.

142
00:07:52,680 --> 00:07:56,440
So in order to create an object from a class.

143
00:07:56,610 --> 00:07:59,540
First of all you're literally first to the name of that class.

144
00:07:59,550 --> 00:08:03,050
So the name of my class is Lion as you can see here.

145
00:08:03,060 --> 00:08:04,010
OK.

146
00:08:04,350 --> 00:08:07,500
So so here I just need to type in line.

147
00:08:07,980 --> 00:08:11,640
So as you can see here the name of my class is lion.

148
00:08:11,910 --> 00:08:12,500
OK.

149
00:08:12,600 --> 00:08:16,650
And here I want to give a name to my lion object.

150
00:08:16,650 --> 00:08:25,380
So the name of my your object is my lion and then I want to instantiate my lion object.

151
00:08:25,410 --> 00:08:26,000
OK.

152
00:08:26,100 --> 00:08:32,870
I put an assignment operator here and then I'll use the new keyboard here.

153
00:08:33,030 --> 00:08:34,430
OK this is very important.

154
00:08:34,500 --> 00:08:41,670
Whenever that you want to create an object from a class you need to put this new keyboard after the

155
00:08:41,670 --> 00:08:43,350
assignment operator OK.

156
00:08:43,500 --> 00:08:49,500
This new key word means that we want to create a new object from that specific class.

157
00:08:49,500 --> 00:08:54,170
In this case we want to create a new object from this class.

158
00:08:54,210 --> 00:08:54,900
OK.

159
00:08:55,060 --> 00:09:02,790
So new and again I need to refer to the name of my class line and then I put a pair of round brackets

160
00:09:03,090 --> 00:09:04,370
after my class name.

161
00:09:04,890 --> 00:09:08,070
And then at the end of my statement I need to put in a semi-colon.

162
00:09:08,070 --> 00:09:08,680
OK.

163
00:09:09,000 --> 00:09:12,740
So as you can see here our object is now created.

164
00:09:12,860 --> 00:09:13,410
OK.

165
00:09:13,650 --> 00:09:16,410
So now that our object is created.

166
00:09:16,410 --> 00:09:19,200
So it's going to be saved inside the memory.

167
00:09:19,200 --> 00:09:19,860
OK.

168
00:09:19,980 --> 00:09:25,370
So in order to actually show you how this object is going to be saved inside the memory.

169
00:09:25,440 --> 00:09:29,630
So first of all let me show you the address of this object inside the memory.

170
00:09:29,670 --> 00:09:37,910
So I just need to type in here system that's out that print line and then inside the practices.

171
00:09:38,010 --> 00:09:40,500
I just need to refer to the name of my object.

172
00:09:40,800 --> 00:09:44,980
And then at the end of my statement I need to put in a semi-colon OK.

173
00:09:45,420 --> 00:09:52,470
So now if you run my project as you can see this is the address of our object inside the memory.

174
00:09:52,500 --> 00:09:56,910
Ok you don't need to know that where this object is actually saved.

175
00:09:56,940 --> 00:10:03,580
You just need to know that your object is created and it is stored somewhere inside the memory OK.

