1
00:00:00,300 --> 00:00:02,050
Hi everyone in this story.

2
00:00:02,280 --> 00:00:07,260
I'm going to go ahead and touch about incrementing and decrementing in Java.

3
00:00:07,260 --> 00:00:07,810
OK.

4
00:00:07,980 --> 00:00:10,380
So first we need a Java project.

5
00:00:10,530 --> 00:00:14,380
So just click on this fine Neo and then click on Java project.

6
00:00:14,410 --> 00:00:22,520
OK so far the project name just taken here increment and decrement J.

7
00:00:22,820 --> 00:00:24,630
And click on finish.

8
00:00:24,800 --> 00:00:28,060
So as you can see here our project is now created.

9
00:00:28,190 --> 00:00:30,120
So we need a class for our project.

10
00:00:30,170 --> 00:00:36,000
So just click on this as RC for folder and then click on File new and click on class.

11
00:00:36,020 --> 00:00:36,890
OK.

12
00:00:36,890 --> 00:00:39,140
So for the class name just type in here increment

13
00:00:42,490 --> 00:00:44,670
OK for the package name.

14
00:00:44,780 --> 00:00:46,810
We need to reverse domain.

15
00:00:47,120 --> 00:00:51,040
So just type in here com that's your name.

16
00:00:51,440 --> 00:00:52,050
OK.

17
00:00:52,230 --> 00:00:53,590
That's your project name.

18
00:00:53,600 --> 00:00:54,350
OK.

19
00:00:54,560 --> 00:01:06,160
Increment and decrements OK and for the modifiers to publish and make sure that you take this checkbox

20
00:01:06,220 --> 00:01:09,170
he had public that it would mean method.

21
00:01:09,370 --> 00:01:13,470
This is going to be the starting point for running our Java code.

22
00:01:13,510 --> 00:01:14,270
OK.

23
00:01:14,290 --> 00:01:16,000
And then click on finish.

24
00:01:16,570 --> 00:01:19,380
So as you can see our class is now created.

25
00:01:19,510 --> 00:01:21,440
So just delete this comment here.

26
00:01:21,770 --> 00:01:27,970
And in order to make this edits have Area Vider just double click on the tap here increment decrement

27
00:01:28,030 --> 00:01:28,770
that go with.

28
00:01:28,810 --> 00:01:29,500
OK.

29
00:01:29,980 --> 00:01:33,680
So as you can see here our editor area is now wider.

30
00:01:33,730 --> 00:01:35,320
So now we can write our code.

31
00:01:35,350 --> 00:01:36,100
OK.

32
00:01:36,250 --> 00:01:39,340
So as you know I'm going to talk about incrementing

33
00:01:41,760 --> 00:01:44,110
and decrementing in Java

34
00:01:51,960 --> 00:02:02,350
so another common task required in programming is to add or subtract one value from an integer value.

35
00:02:02,420 --> 00:02:10,670
OK those expressions have special operators which are called increment and decrement operators.

36
00:02:10,700 --> 00:02:15,910
OK incrementing a valuable means adding one value to its value.

37
00:02:15,930 --> 00:02:16,460
OK.

38
00:02:16,620 --> 00:02:22,330
And decrement in a variable means subtracting one value from its value.

39
00:02:22,340 --> 00:02:27,950
OK the increment operator is this operator here and

40
00:02:30,660 --> 00:02:33,900
and the decrement operator is this operator here.

41
00:02:33,960 --> 00:02:40,430
OK these operators are placed immediately after or before a variable name.

42
00:02:40,620 --> 00:02:46,230
So let me actually show you some real examples in order to make this concept more clear for you.

43
00:02:46,230 --> 00:02:46,690
OK.

44
00:02:46,950 --> 00:02:54,000
So for example I want to create a variable the data type of my variable is int and the name of my variable

45
00:02:54,000 --> 00:02:54,260
is.

46
00:02:54,260 --> 00:02:57,070
For example my value OK.

47
00:02:57,510 --> 00:02:59,490
And then I assign a value to my value.

48
00:02:59,490 --> 00:03:01,120
But for example number seven.

49
00:03:01,290 --> 00:03:05,030
And then at the end of my statement I need to put in a semi-colon.

50
00:03:05,340 --> 00:03:08,060
So now I want to use these operators here.

51
00:03:08,070 --> 00:03:13,330
OK so for example I want to add one value to the value of this variable here.

52
00:03:13,440 --> 00:03:19,840
So as you know these operators are placed immediately after or before the variable name.

53
00:03:20,040 --> 00:03:24,100
OK so I just need to refer to the name of my variable.

54
00:03:24,450 --> 00:03:24,980
OK.

55
00:03:24,990 --> 00:03:27,080
Now I want to put this operator here.

56
00:03:27,120 --> 00:03:28,410
OK.

57
00:03:28,530 --> 00:03:30,840
Increment operator.

58
00:03:30,840 --> 00:03:32,010
So as you can see here.

59
00:03:32,010 --> 00:03:38,220
So now if I want to output the value of this variable to the console I just need to type in here system

60
00:03:39,270 --> 00:03:47,080
data out that print line and then inside Apprentice's I just need to refer to the name of my variable.

61
00:03:47,640 --> 00:03:50,830
And then at the end of my statement I need to put in a semicolon.

62
00:03:50,840 --> 00:03:51,320
OK.

63
00:03:51,540 --> 00:03:55,050
So now if I run my project let's see what happens.

64
00:03:55,050 --> 00:03:58,340
So as you can see this value is outputted to the console.

65
00:03:58,360 --> 00:03:58,910
OK.

66
00:03:59,160 --> 00:04:02,300
So this is the value of this variable here.

67
00:04:02,310 --> 00:04:02,900
OK.

68
00:04:03,120 --> 00:04:05,810
So now I want to use the increment operator here.

69
00:04:05,880 --> 00:04:06,330
OK.

70
00:04:06,360 --> 00:04:12,250
As you know these operators are placed immediately after or before the variable name.

71
00:04:12,330 --> 00:04:12,890
OK.

72
00:04:13,110 --> 00:04:17,000
So I just need to the first with the name of my variable my value.

73
00:04:17,180 --> 00:04:17,780
OK.

74
00:04:17,820 --> 00:04:20,750
And then I need to put in the increment operator here.

75
00:04:20,790 --> 00:04:21,370
OK.

76
00:04:21,570 --> 00:04:22,650
Plus plus.

77
00:04:22,650 --> 00:04:25,880
And then I need to put the semi-colon at the end of my statement.

78
00:04:25,900 --> 00:04:32,740
So now if I want to actually output the value of this variable to the console Let's see what happens.

79
00:04:32,760 --> 00:04:41,960
System that out that princeling and an insight Apprentice's I need to refer to the name of my valuable

80
00:04:42,050 --> 00:04:44,430
my value.

81
00:04:44,570 --> 00:04:46,910
I need to put in a semi-colon.

82
00:04:47,210 --> 00:04:50,730
So now if I run my project let's see what happens.

83
00:04:50,870 --> 00:04:53,780
As you can see the first value is 7.

84
00:04:53,900 --> 00:04:56,070
So this is the value of our value.

85
00:04:56,120 --> 00:05:01,670
And we decided to output this value to the concert in line 14.

86
00:05:01,760 --> 00:05:05,670
And as you can see this is the result of execution of this line of code here.

87
00:05:05,690 --> 00:05:06,200
OK.

88
00:05:06,350 --> 00:05:12,370
And in line 16 we decided to add one value to the value of our variable here.

89
00:05:12,380 --> 00:05:13,020
OK.

90
00:05:13,220 --> 00:05:19,690
And in line 17 we decided to output this value to the console.

91
00:05:19,760 --> 00:05:25,850
So as you can see this is the value that is output to the console after the increment of this value.

92
00:05:25,910 --> 00:05:26,720
OK.

93
00:05:27,350 --> 00:05:29,840
So now let me try show you another example.

94
00:05:29,850 --> 00:05:34,020
So now let me comment out this line of code here.

95
00:05:34,970 --> 00:05:41,170
So for example again I want to actually subtract one value from this variable here.

96
00:05:41,180 --> 00:05:41,870
OK.

97
00:05:42,360 --> 00:05:46,250
I want to subtract one value from the value of this variable here.

98
00:05:46,280 --> 00:05:46,880
OK.

99
00:05:47,120 --> 00:05:52,730
So again I just need to refer to the name of my variable and then I need to put the increment operator

100
00:05:52,740 --> 00:05:58,180
here minus minus and then at the end of my statement I need to put in a semi-colon.

101
00:05:58,190 --> 00:06:04,310
So now if I want to output the value of this value over to the console system that out that print learn

102
00:06:05,330 --> 00:06:10,820
and then inside the practices I just need to refer to the name of my valuable at the end of my statement.

103
00:06:10,830 --> 00:06:12,610
I need to put in a semi-colon.

104
00:06:12,620 --> 00:06:21,140
So now if I run my project as you can see the first value is 7 because this is the value that we assign

105
00:06:21,440 --> 00:06:29,330
to our variable when we created this variable and in line 14 we decided to output this value to the

106
00:06:29,330 --> 00:06:29,750
console.

107
00:06:29,750 --> 00:06:38,600
So this is the value of a variable and in line 19 we decided to actually subtract one value from the

108
00:06:38,600 --> 00:06:40,130
value of this variable here.

109
00:06:40,160 --> 00:06:40,710
Okay.

110
00:06:40,880 --> 00:06:46,410
And in line 29 we decided to output this value to the console.

111
00:06:46,490 --> 00:06:50,610
So this is the value of our value bet after the subtraction.

112
00:06:50,630 --> 00:06:51,490
OK.

113
00:06:52,160 --> 00:06:55,970
So let me actually show you another example.

114
00:06:55,970 --> 00:06:58,920
So let me ask you to comment out these lines of code here.

115
00:07:00,710 --> 00:07:01,720
OK.

116
00:07:02,440 --> 00:07:08,220
I want to declare another variable here is another value.

117
00:07:08,900 --> 00:07:12,460
And then I can assign a value to my value but for example number 20.

118
00:07:12,460 --> 00:07:13,020
Okay.

119
00:07:13,460 --> 00:07:20,440
And I want to output the value of this variable to the console system that out that princeling.

120
00:07:21,380 --> 00:07:26,470
And then inside Apprentice's I naturally first with the name of my valuable and other value.

121
00:07:26,750 --> 00:07:30,020
And then at the end of my statement I need to put in a semicolon.

122
00:07:30,020 --> 00:07:37,340
OK so now I want to actually run my project as you can see this value is out to the concert.

123
00:07:37,340 --> 00:07:37,710
OK.

124
00:07:37,760 --> 00:07:40,480
So for example I want to increment this value by 1.

125
00:07:40,600 --> 00:07:41,140
OK.

126
00:07:41,360 --> 00:07:46,140
So I just need to refer to the name of my body but in order to read it's value.

127
00:07:46,160 --> 00:07:46,850
OK.

128
00:07:47,080 --> 00:07:52,430
And now I want to increment the value of this variable by 1.

129
00:07:52,480 --> 00:07:52,980
OK.

130
00:07:53,000 --> 00:07:57,260
So I just need to put in here the increment operator plus plus.

131
00:07:57,500 --> 00:08:01,270
And then I need to put in a semi-colon at the end of my statement.

132
00:08:01,280 --> 00:08:08,600
So now if you run my project as you can see all I did I forgot to actually output the value of this

133
00:08:08,600 --> 00:08:10,390
variable to the concert.

134
00:08:10,490 --> 00:08:17,470
So system that out that creates land and then inside the.

135
00:08:17,530 --> 00:08:23,860
I just need to refer to the name of my variable and at the end of my statement I need to put in a semicolon.

136
00:08:23,860 --> 00:08:24,430
OK.

137
00:08:24,790 --> 00:08:30,800
So now if I run my project as you can see this is the value that is output to the console.

138
00:08:30,850 --> 00:08:36,140
And this is the value that we assigned to our variable when we actually created our variable.

139
00:08:36,220 --> 00:08:42,850
Ok as you can see and in line 23 of we decided to output this value to the consumer.

140
00:08:43,180 --> 00:08:51,130
So this is our value and in line 25 I decided to increment this value by 1.

141
00:08:51,340 --> 00:08:52,160
Okay.

142
00:08:52,180 --> 00:08:57,840
And in line 26 I decided to output this value to the console.

143
00:08:57,940 --> 00:08:58,390
Okay.

144
00:08:58,510 --> 00:08:59,650
Which is 21.

145
00:08:59,830 --> 00:09:00,400
Okay.

146
00:09:00,580 --> 00:09:04,840
So now that you actually comment out these lines of code here.

147
00:09:05,230 --> 00:09:06,090
Okay.

148
00:09:06,580 --> 00:09:10,460
And now I want to decrement the value of this variable by one.

149
00:09:10,480 --> 00:09:11,040
Okay.

150
00:09:11,230 --> 00:09:13,980
So again I need to refer to the name of my body.

151
00:09:14,220 --> 00:09:17,850
And then I need to put in the decrement operator here.

152
00:09:17,860 --> 00:09:18,470
Okay.

153
00:09:18,670 --> 00:09:22,230
And then at the end of my statement I need to put in a semi-colon.

154
00:09:22,460 --> 00:09:26,300
So now I want to output the value of this variable to the console.

155
00:09:26,530 --> 00:09:35,120
So now let me actually run my project as you can see it's going to only output this value to the concert.

156
00:09:35,120 --> 00:09:35,610
Okay.

157
00:09:35,800 --> 00:09:41,910
And this value here is the result of execution of this line of code here.

158
00:09:41,950 --> 00:09:42,810
Okay.

159
00:09:43,210 --> 00:09:51,180
And as you know in line 28 I actually subtracted the value of this valuable one.

160
00:09:51,640 --> 00:09:57,910
But as you can see it's not streaming the concert because I didn't write any code in order to output

161
00:09:58,000 --> 00:10:00,940
the value of this variable after the discrimination.

