1
00:00:01,080 --> 00:00:07,860
So now in order to actually create another package just click on this as artsy folder and then click

2
00:00:07,860 --> 00:00:11,130
on File New and then click on package.

3
00:00:11,390 --> 00:00:14,490
So for the package name we need our reverse domain here.

4
00:00:14,610 --> 00:00:22,390
So that statement here com that your name dot custom package.

5
00:00:23,090 --> 00:00:23,830
OK.

6
00:00:24,150 --> 00:00:25,800
And then click on finish.

7
00:00:25,950 --> 00:00:29,380
So as you can see here our package is now created.

8
00:00:29,400 --> 00:00:34,170
So now I want to create another class and put that class inside the spy cage.

9
00:00:34,170 --> 00:00:39,800
So just click on this package and then click on File Neal and then click on class.

10
00:00:40,230 --> 00:00:45,640
So for the class name just type in here custom class.

11
00:00:45,770 --> 00:00:46,370
OK.

12
00:00:46,590 --> 00:00:49,150
And for the modifiers choose public.

13
00:00:49,380 --> 00:00:51,440
And here check the sequence here.

14
00:00:51,450 --> 00:00:55,100
Public is static void main method and then click on finish.

15
00:00:55,530 --> 00:00:58,660
So as you can see here our class is now created.

16
00:00:58,830 --> 00:01:02,770
So now I want to actually create an object from the start class.

17
00:01:02,790 --> 00:01:03,280
OK.

18
00:01:03,480 --> 00:01:09,450
So first I need to refer to the name of my class dog and then I need to give my object a name.

19
00:01:09,450 --> 00:01:18,620
For example dog 1 and then I put an assignment operator here and then I use this vote here new.

20
00:01:19,080 --> 00:01:26,790
And then I refer to the name of my class dog and I actually put a pair of round brackets after my class

21
00:01:26,790 --> 00:01:27,020
name.

22
00:01:27,030 --> 00:01:27,450
OK.

23
00:01:27,510 --> 00:01:30,910
And then I need to put in a semicolon at the end of my statement.

24
00:01:31,020 --> 00:01:34,610
So as you can see here it's now showing us an error.

25
00:01:34,620 --> 00:01:39,030
OK so let's hover over the error area and see what's the error.

26
00:01:39,030 --> 00:01:46,890
So as you can see here dog can not be resolved to a type and this means this class doesn't recognize

27
00:01:47,100 --> 00:01:49,230
this dog that Java class.

28
00:01:49,430 --> 00:01:50,140
OK.

29
00:01:50,340 --> 00:01:51,990
It doesn't recognize this class.

30
00:01:52,150 --> 00:01:54,040
OK so what's the problem.

31
00:01:54,090 --> 00:01:59,100
The problem is this custom class that Java is inside this package.

32
00:01:59,130 --> 00:01:59,500
OK.

33
00:01:59,520 --> 00:02:06,660
And this class is inside this package and this class can not refer to the name of its class in order

34
00:02:06,660 --> 00:02:08,080
to create objects.

35
00:02:08,190 --> 00:02:12,330
In other words this class doesn't recognize this class.

36
00:02:12,340 --> 00:02:13,870
Ok inside this package.

37
00:02:13,890 --> 00:02:20,550
So in order to actually allow this class this custom class that Jarba to create objects from this dog

38
00:02:20,830 --> 00:02:30,120
Java class we need to import the address of this dog Java class or the address of this package to this

39
00:02:30,120 --> 00:02:31,650
custom class that Java.

40
00:02:31,800 --> 00:02:33,700
In order to actually access those classes.

41
00:02:33,720 --> 00:02:42,570
Ok so if you for example import the address of this package inside this class we can actually use all

42
00:02:42,570 --> 00:02:45,260
of the classes inside this package.

43
00:02:45,270 --> 00:02:45,830
OK.

44
00:02:45,900 --> 00:02:53,550
But if you only actually import the address of this class to this package you can only actually use

45
00:02:53,610 --> 00:02:56,290
this class inside your custom class that job.

46
00:02:56,310 --> 00:03:03,020
OK so I prefer for now to actually import the address of this package to this class.

47
00:03:03,040 --> 00:03:06,100
Ok inside your custom class that Jobab.

48
00:03:06,180 --> 00:03:08,680
And before the class creation type in here.

49
00:03:08,700 --> 00:03:09,830
Import.

50
00:03:10,410 --> 00:03:11,310
OK.

51
00:03:11,400 --> 00:03:14,370
Come dot Mortaza

52
00:03:17,520 --> 00:03:19,160
getters and setters.

53
00:03:19,200 --> 00:03:29,240
So as you can see here we managed to successfully import the address of this package to our custom class

54
00:03:29,250 --> 00:03:29,980
that Java.

55
00:03:30,090 --> 00:03:32,480
OK this class is inside of this package.

56
00:03:32,490 --> 00:03:33,010
OK.

57
00:03:33,030 --> 00:03:35,540
Can't that mortiser that custom package.

58
00:03:35,550 --> 00:03:36,190
OK.

59
00:03:36,360 --> 00:03:39,110
And now as you can see the error is gone.

60
00:03:39,210 --> 00:03:45,150
OK so we can actually access all of the classes that is inside of this package.

61
00:03:45,150 --> 00:03:46,050
OK.

62
00:03:46,320 --> 00:03:52,130
So now I want to actually access the speed instance variable of these thugs one object.

63
00:03:52,140 --> 00:03:52,910
OK.

64
00:03:53,310 --> 00:03:55,880
And then I want to output that value to the console.

65
00:03:55,950 --> 00:04:04,770
So I just need to type in here a system that out that Pantalone and that inside the prentices I need

66
00:04:04,770 --> 00:04:08,770
to refer to the name of my object Doug.

67
00:04:09,030 --> 00:04:19,690
One that's get speed and then I need to put in a semi-colon at the end of my statement.

68
00:04:19,810 --> 00:04:23,350
So as you can see here it's now showing us an error.

69
00:04:23,350 --> 00:04:30,260
So let's actually hover over the error area and see what's the error the Mefford get speed from the

70
00:04:30,260 --> 00:04:30,650
type.

71
00:04:30,650 --> 00:04:32,560
Doug is not visible.

72
00:04:32,750 --> 00:04:41,690
So as you can see here we cannot refer to the get speed method of this object from this class.

73
00:04:41,690 --> 00:04:44,090
OK so what's the problem.

74
00:04:44,090 --> 00:04:45,150
So let's go inside.

75
00:04:45,250 --> 00:04:46,620
Dog the java file.

76
00:04:46,790 --> 00:04:54,980
As you can see here in this class this method uses the package as it's access modifying the access modifier

77
00:04:54,980 --> 00:05:01,860
of the Smurfette is package and package means that this method is only visible to the whole package.

78
00:05:02,000 --> 00:05:09,800
And it means that this method is only visible to the classes of this package not classes in another

79
00:05:09,800 --> 00:05:10,560
package.

80
00:05:10,850 --> 00:05:19,550
So in order to solve this problem we need to use another access modifier public so public means visible

81
00:05:19,640 --> 00:05:20,660
to the whole world.

82
00:05:20,720 --> 00:05:21,610
OK.

83
00:05:21,740 --> 00:05:27,180
And as you can see here inside the custom cluster Java now the error is gone.

84
00:05:27,340 --> 00:05:27,830
OK.

85
00:05:28,010 --> 00:05:34,970
And I managed to successfully access this get speed method and now I can actually output that value

86
00:05:34,970 --> 00:05:35,680
to the console.

87
00:05:35,780 --> 00:05:43,310
So now if I want to run the code inside this method inside the main effort of this custom class I just

88
00:05:43,310 --> 00:05:49,240
need to right click on this class and then click on run as job application.

89
00:05:49,820 --> 00:05:56,670
So as you can see here disvalue is the value of this speed instance variable of this object.

90
00:05:56,690 --> 00:05:57,520
OK.

91
00:05:57,890 --> 00:06:00,890
And the value of this bit in this variable is 70.

92
00:06:00,890 --> 00:06:01,890
OK.

93
00:06:02,000 --> 00:06:09,140
So that's it that's how you can actually access the instance variables of another class inside another

94
00:06:09,140 --> 00:06:09,580
package.

95
00:06:09,590 --> 00:06:10,930
OK you can see here.

96
00:06:11,180 --> 00:06:12,130
This is public.

97
00:06:12,140 --> 00:06:16,400
Or create a public access modifier means visible to the whole world.

98
00:06:16,640 --> 00:06:23,210
And when you use the public access modifier on MFL or on a variable that Mefford or valuable is going

99
00:06:23,210 --> 00:06:26,580
to be visible to all the java files of that project.

100
00:06:26,630 --> 00:06:31,240
OK so the next access modifier which is very important is private.

101
00:06:31,430 --> 00:06:38,690
So remember that inside the mind that Java class I could successfully access the instance variables

102
00:06:38,750 --> 00:06:41,890
of this my first talk object directly.

103
00:06:41,990 --> 00:06:42,690
OK.

104
00:06:42,950 --> 00:06:50,180
And this is the code that proves that I can't directly access the speed instance variable directly.

105
00:06:50,200 --> 00:06:53,090
OK so now let me actually delete this line of code here.

106
00:06:53,210 --> 00:07:00,500
In order not to allow any other classes other than this thug class to access its instance variables

107
00:07:00,500 --> 00:07:06,910
directly we need to use an ORDER access modifier which is private.

108
00:07:07,010 --> 00:07:10,760
So now let's go inside the main Java class.

109
00:07:10,760 --> 00:07:14,050
So as you can see here it's now showing us an error.

110
00:07:14,060 --> 00:07:14,460
OK.

111
00:07:14,600 --> 00:07:21,480
So as you can see here this class doesn't recognize this speed instance variable no longer.

112
00:07:21,650 --> 00:07:29,780
OK so we cannot actually access this speed instance valuable directly because we used these private

113
00:07:29,900 --> 00:07:37,640
access modifier and this access modifier private means that this variable is only visible inside of

114
00:07:37,640 --> 00:07:38,510
this class.

115
00:07:38,600 --> 00:07:40,430
Ok inside of this Java.

116
00:07:40,490 --> 00:07:41,130
OK.

117
00:07:41,360 --> 00:07:46,060
And we cannot use this instance variable from any places other than this class.

118
00:07:46,090 --> 00:07:49,250
Ok this instance valuable is private.

119
00:07:49,250 --> 00:07:57,200
So in order to actually access the value of the speed instance variable we must use this get help method.

120
00:07:57,200 --> 00:07:59,080
OK great speed.

121
00:07:59,090 --> 00:08:06,590
So now if I want to actually correct this error I just need to delete this speed instance variable and

122
00:08:06,590 --> 00:08:10,850
then I need to refer to the name of my get speed Meffert.

123
00:08:11,000 --> 00:08:17,170
So now I can actually access the value of that speed instance variable.

124
00:08:17,180 --> 00:08:24,120
So now if I get on my project as you can see the value of this sweet instance variable is 70.

125
00:08:24,350 --> 00:08:30,130
OK so that's how you can actually use the access modifiers in your codes.

126
00:08:30,280 --> 00:08:37,150
OK we've got another access modifier in Java which I'll tell you more about in the next tutorials.

127
00:08:37,160 --> 00:08:37,580
OK.

128
00:08:37,640 --> 00:08:44,680
Now I want to actually tell you another important point about running our Java projects.

129
00:08:44,740 --> 00:08:53,420
Ok so now if I actually write you click on these get hairs and set her project as you can see here and

130
00:08:53,420 --> 00:08:58,730
then click on runners and then click on Java application.

131
00:08:58,730 --> 00:09:02,230
So as you can see here it's now showing us this window here.

132
00:09:02,240 --> 00:09:02,790
OK.

133
00:09:02,870 --> 00:09:13,340
And here it says matching items main dash cam that Mortaza dot getters and setters workspace matches

134
00:09:14,270 --> 00:09:18,950
custom class dash cam that mortars or that custom package.

135
00:09:18,950 --> 00:09:25,860
So as you can see here because we've got two main methods inside of these classes the main class and

136
00:09:25,860 --> 00:09:31,970
the custom class it's now asking us to determine which one of the classes we want to run.

137
00:09:31,970 --> 00:09:38,870
So if I actually click on this option here it's going to actually run the codes inside the main method

138
00:09:39,110 --> 00:09:40,570
that is inside the main class.

139
00:09:40,580 --> 00:09:41,240
OK.

140
00:09:41,450 --> 00:09:42,330
As you can see here.

141
00:09:42,530 --> 00:09:48,450
But if we actually choose this option here it's going to actually run the code inside the main method.

142
00:09:48,500 --> 00:09:50,860
Inside the custom class that job.

143
00:09:50,870 --> 00:09:51,490
OK.

144
00:09:51,500 --> 00:09:56,730
So here I can actually choose which one of these classes I want to run.

145
00:09:56,740 --> 00:09:57,170
OK.

146
00:09:57,200 --> 00:10:04,520
So if I actually choose this option and then click on OK it's going to actually execute the code inside

147
00:10:04,790 --> 00:10:08,430
of the main effect of this main class.

148
00:10:08,450 --> 00:10:08,900
OK.

