1
00:00:00,660 --> 00:00:07,010
So now inside the main class I just need to refer to the name of my class that speed.

2
00:00:07,580 --> 00:00:07,850
OK.

3
00:00:07,860 --> 00:00:15,530
As you can see I managed to successfully access this class valuable OK by just using the class itself.

4
00:00:15,750 --> 00:00:17,800
And then I put the dot notation here.

5
00:00:17,970 --> 00:00:21,600
And then I accessed this class variable here.

6
00:00:21,600 --> 00:00:27,000
So now if I want to output the value of my class value to the console I just need to type in here system

7
00:00:27,810 --> 00:00:35,000
that out that insulin and then inside the apprentice's I can just put this statement here.

8
00:00:35,190 --> 00:00:35,620
OK.

9
00:00:35,730 --> 00:00:38,980
And then I need to put in a semicolon at the end of my statement.

10
00:00:39,180 --> 00:00:45,760
And now if I get on my project as you can see this is the value of the speed class variable.

11
00:00:45,800 --> 00:00:46,190
OK.

12
00:00:46,200 --> 00:00:47,470
One hundred and eighty.

13
00:00:47,640 --> 00:00:52,750
OK so as you can see here are the value of this class variable is one hundred and eighty.

14
00:00:52,870 --> 00:00:56,480
OK so now I want to actually create a class method.

15
00:00:56,520 --> 00:01:02,290
So let me try to change this public access modifier to private OK.

16
00:01:02,490 --> 00:01:10,980
And then let me actually delete this static keyword here and now I want to actually create a class method.

17
00:01:11,070 --> 00:01:15,390
So after this public access modify it I just need to type in static.

18
00:01:16,230 --> 00:01:20,430
And as you can see here it's going to actually show us an error here.

19
00:01:20,430 --> 00:01:27,630
So let's actually hover over the error area and see what's the error cannot make a static reference

20
00:01:27,960 --> 00:01:30,180
to the non-static field speed.

21
00:01:30,180 --> 00:01:30,680
OK.

22
00:01:30,780 --> 00:01:36,750
So as you can see here it says that our speed instance variable here is not static.

23
00:01:36,900 --> 00:01:40,770
So we must actually put the static keyword here.

24
00:01:41,070 --> 00:01:44,930
In order to refer to this special class variable here.

25
00:01:44,940 --> 00:01:45,380
OK.

26
00:01:45,390 --> 00:01:49,610
Because you actually changed this method to a class method.

27
00:01:49,650 --> 00:01:56,550
OK we put this static vote after our public access modifier in order to make this method a class method.

28
00:01:56,670 --> 00:01:57,050
OK.

29
00:01:57,060 --> 00:01:59,590
Before that it was only an instance method.

30
00:01:59,620 --> 00:02:03,290
OK but now it is a class method.

31
00:02:03,540 --> 00:02:05,620
So here inside the main class.

32
00:02:05,640 --> 00:02:07,960
So as you can see here it's now showing us an error.

33
00:02:08,100 --> 00:02:14,700
So if I hover over the area it says the field where that speed is not visible because we actually changed

34
00:02:14,910 --> 00:02:18,500
the axis modifier of this class variable to private.

35
00:02:18,510 --> 00:02:24,610
So we have not referred to this class variable from outside of this class.

36
00:02:24,750 --> 00:02:27,080
So I just need to delete this line of code here.

37
00:02:27,420 --> 00:02:33,170
And now I want to actually see the value of that speed class variable by using that term ever.

38
00:02:33,180 --> 00:02:40,070
Ok so I just need to type in here system that out that gentleman and it inside the.

39
00:02:40,290 --> 00:02:43,580
I can just refer to the name of my class Bert.

40
00:02:44,480 --> 00:02:50,940
OK that gets spit and then at the end of my statement I need to put in a semi-colon.

41
00:02:50,940 --> 00:02:57,450
So as you can see here if I run my project as you can see this is the value of that speed class variable.

42
00:02:57,540 --> 00:02:58,350
OK.

43
00:02:58,890 --> 00:03:04,750
So I managed to successfully access the value of this Spaeth class variable.

44
00:03:05,010 --> 00:03:05,640
OK.

45
00:03:05,640 --> 00:03:10,020
So as you can see here I didn't create any object from this class.

46
00:03:10,050 --> 00:03:16,530
I did actually referred to the name of this class and then I did access this my fed by just referring

47
00:03:16,570 --> 00:03:17,520
to the name of this method.

48
00:03:17,550 --> 00:03:18,070
OK.

49
00:03:18,090 --> 00:03:20,670
And that's because of these static keyword here.

50
00:03:20,760 --> 00:03:21,330
OK.

51
00:03:21,330 --> 00:03:28,440
In order to make a valuable or a method a class valuable or a class method we need to put the static

52
00:03:28,440 --> 00:03:30,640
keyword after our access modifier.

53
00:03:30,660 --> 00:03:31,510
OK.

54
00:03:31,830 --> 00:03:39,040
And here again I can actually put this static keyword here static and it inside of the main class.

55
00:03:39,160 --> 00:03:43,060
I can just refer to the name of this class method.

56
00:03:43,110 --> 00:03:50,640
And now I can just refer to the name of my class bird that said speed and I can actually pass a value

57
00:03:50,640 --> 00:03:51,300
to this.

58
00:03:51,300 --> 00:03:53,450
For example number 25.

59
00:03:53,790 --> 00:04:00,360
And here as you can see I actually changed the value of this speed class variable here.

60
00:04:00,440 --> 00:04:03,780
OK the value of this speed class value is 25.

61
00:04:03,900 --> 00:04:11,430
And remember that I told you this earlier in this tutorial with class variables only one copy of that

62
00:04:11,430 --> 00:04:14,420
value exists when the class is loaded.

63
00:04:14,560 --> 00:04:20,880
Changing the value of that variable changes it for all instances of that class.

64
00:04:20,880 --> 00:04:21,380
OK.

65
00:04:21,600 --> 00:04:26,750
So now the value of the speed class value is 25.

66
00:04:26,790 --> 00:04:34,680
And if you create any object from that birth class the value of that Spaeth class valuable is 25 not

67
00:04:34,680 --> 00:04:35,990
one hundred and eighty.

68
00:04:36,090 --> 00:04:36,770
OK.

69
00:04:37,050 --> 00:04:43,080
So as you can see here if you want to access the value of that speed class variable and output that

70
00:04:43,080 --> 00:04:44,120
value to the console.

71
00:04:44,220 --> 00:04:52,950
Let's see what happens system that out that insulin and that inside the prentices I can just refer to

72
00:04:52,950 --> 00:05:01,640
the name of my class bird that gets beat and then at the end of my statement I need to put in a semi-colon.

73
00:05:01,830 --> 00:05:07,400
So now if you're on my project as you can see the value of that class variable and the value of the

74
00:05:07,400 --> 00:05:09,540
speed class value bet is 25.

75
00:05:09,690 --> 00:05:15,390
And now I want to actually create an object from this birth class.

76
00:05:15,390 --> 00:05:17,500
So I just need what I can hear birds.

77
00:05:18,030 --> 00:05:23,590
And the name of my object is my second bird.

78
00:05:24,180 --> 00:05:30,220
And then I put an assignment operator here and I put this key vote here Neo.

79
00:05:30,390 --> 00:05:37,690
And then I refer to the name of my class bird and then I put in a program and I get after my class.

80
00:05:37,770 --> 00:05:43,260
And here I want to actually access the value of this speech class value add and outputs that value to

81
00:05:43,260 --> 00:05:43,770
the concert.

82
00:05:43,770 --> 00:05:44,230
OK.

83
00:05:44,340 --> 00:05:50,190
So I just need to type in here system that out that printed then and then inside the parenthesis I can't

84
00:05:50,190 --> 00:05:51,930
just refer to the name of my object.

85
00:05:51,930 --> 00:06:04,420
My second bird that gets speed we can actually refer to our class benefits by using odd objects.

86
00:06:04,440 --> 00:06:04,840
OK.

87
00:06:04,860 --> 00:06:10,880
So now if I don't on my project as you can see the value of the speed class variable is again 25.

88
00:06:10,890 --> 00:06:11,630
Why.

89
00:06:11,670 --> 00:06:15,510
Because this speed valuable is actually a class variable.

90
00:06:15,540 --> 00:06:16,010
OK.

91
00:06:16,170 --> 00:06:23,160
And if we change the value of this variable that value is going to be changed for all of our instances

92
00:06:23,160 --> 00:06:24,060
from this class.

93
00:06:24,060 --> 00:06:24,720
OK.

94
00:06:24,900 --> 00:06:28,140
And let me actually tell you again with class variables.

95
00:06:28,170 --> 00:06:32,290
Only one copy of that variable exists when the class is loaded.

96
00:06:32,310 --> 00:06:32,980
OK.

97
00:06:33,000 --> 00:06:38,450
Changing the value of that variable changes it for all instances of that class.

98
00:06:38,660 --> 00:06:45,060
OK so now if I actually want to change that value again I just need to type in here my second bird that

99
00:06:45,420 --> 00:06:49,320
said speed for example 45.

100
00:06:49,830 --> 00:06:55,210
And as you can see the value of this class variable is 45.

101
00:06:55,380 --> 00:07:00,250
And if you want to output that value to the console I just need to type in here a system that out that

102
00:07:00,340 --> 00:07:05,850
insulin and and inside the prentices I just need to refer to the name of my object or I can actually

103
00:07:05,850 --> 00:07:13,860
refer to the name of my class because that's value it is a class variable that gets beat and I need

104
00:07:13,860 --> 00:07:16,220
to put in a semicolon at the end of my statement.

105
00:07:16,530 --> 00:07:21,680
And if I run my project again as you can see the value of the speed class value is 45.

106
00:07:21,740 --> 00:07:22,420
OK.

107
00:07:22,530 --> 00:07:29,610
And now if I want to actually create another object from my birth class I just need to type in here

108
00:07:29,640 --> 00:07:37,820
word my first birth and then I put an assignment operator here.

109
00:07:38,010 --> 00:07:44,010
And then I put the new word here and then I refer to the name of my class and I put in a pair of round

110
00:07:44,010 --> 00:07:46,120
brackets after my class name.

111
00:07:46,170 --> 00:07:49,790
So as you can see here my first birth object is now created.

112
00:07:49,950 --> 00:07:55,400
So I even try to access the value of this Spaeth class variable and outputs that value to the console.

113
00:07:55,410 --> 00:08:03,360
So I just need to type in here a system that's out to print to learn and then inside the apprentice's

114
00:08:03,630 --> 00:08:08,880
I can just refer to the name of my object or I can refer to the name of my class.

115
00:08:08,880 --> 00:08:19,470
My first object that get speed and as you can see it's going to output the value number 45 to the console.

116
00:08:19,710 --> 00:08:21,600
So as you can see here this is that video.

117
00:08:21,600 --> 00:08:22,190
OK.

118
00:08:22,410 --> 00:08:27,980
And inside that first class I can even change the Smurfette this instance method.

119
00:08:28,020 --> 00:08:35,730
So know that we call these behaviors instance Smif it's OK if we don't put the static keyboard before

120
00:08:35,740 --> 00:08:36,600
the method itself.

121
00:08:36,660 --> 00:08:37,030
OK.

122
00:08:37,050 --> 00:08:44,270
If we put this static keyboard after this axis modifier static as a citizen if it is going to be a class

123
00:08:44,400 --> 00:08:44,790
it.

124
00:08:44,880 --> 00:08:45,530
OK.

125
00:08:45,810 --> 00:08:53,430
So inside the main class I can't even the first of the name of my class bird does fly.

126
00:08:54,240 --> 00:08:58,950
So I can't even run my project as I can see this value is output to the console.

127
00:08:58,990 --> 00:09:06,740
OK so now I want to actually show you another important point about class methods in Java.

128
00:09:06,750 --> 00:09:10,320
So for example inside the main class I want to create MFA.

129
00:09:10,350 --> 00:09:10,870
OK.

130
00:09:11,070 --> 00:09:16,830
So here I just need to type in so first that what I need to specify the access modifier of my method.

131
00:09:16,920 --> 00:09:20,080
So the access modifier of mine if it is public.

132
00:09:20,570 --> 00:09:21,200
OK.

133
00:09:21,630 --> 00:09:25,070
And I need to specify the return type of my method.

134
00:09:25,140 --> 00:09:32,560
So the return type of my method void and the name of my method is for example my fifth one.

135
00:09:32,850 --> 00:09:39,030
And then I need to put in a pair of round brackets after my method name and then I need to open and

136
00:09:39,030 --> 00:09:44,160
close my Meffert by using these curly braces and inside the Meffert I can put in my statements.

137
00:09:44,160 --> 00:09:52,950
So I just type in here system that out that princeling line and then inside the apprentice's I can just

138
00:09:53,520 --> 00:09:57,770
put it into double quotes and then inside the code I can put in my text.

