1
00:00:01,320 --> 00:00:03,330
So now let's actually click on this.

2
00:00:03,360 --> 00:00:05,190
Start of the loop button here.

3
00:00:05,460 --> 00:00:07,380
As you can see it says 15.

4
00:00:07,650 --> 00:00:08,130
OK.

5
00:00:08,250 --> 00:00:12,210
So it is actually executing this up do I do 15 times.

6
00:00:12,450 --> 00:00:17,550
So what's the difference between a loop and a do while loop the loop.

7
00:00:17,690 --> 00:00:24,900
You're actually sure that it's going to actually first of all specify that whether this condition is

8
00:00:24,900 --> 00:00:28,990
true or not until it is less than or equal to number 10.

9
00:00:29,190 --> 00:00:33,870
And then it can actually go inside this y loop and then it's going to execute these lines of code.

10
00:00:33,860 --> 00:00:34,760
Here for example.

11
00:00:34,980 --> 00:00:41,140
But do a loop First of all it can actually do these lines of code inside of these curly braces.

12
00:00:41,270 --> 00:00:42,000
OK.

13
00:00:42,030 --> 00:00:46,290
First it's going to actually do these lines of code and then it's going to check the condition.

14
00:00:46,320 --> 00:00:46,820
Why.

15
00:00:46,950 --> 00:00:49,950
Why is less than or equal to number 15.

16
00:00:49,950 --> 00:00:57,420
So in Duvel loop you are sure that your codes inside the DO statement is going to be executed at least

17
00:00:57,420 --> 00:00:58,380
once.

18
00:00:58,690 --> 00:00:59,050
OK.

19
00:00:59,070 --> 00:01:01,270
And then it can actually check the condition.

20
00:01:01,610 --> 00:01:02,050
OK.

21
00:01:02,130 --> 00:01:06,040
First it's going to do these lines of code and then it's going to check the condition.

22
00:01:06,060 --> 00:01:08,220
And then again it's going actually.

23
00:01:08,280 --> 00:01:13,480
And then if the condition is true it is going to again do these lines of code inside of these two statements

24
00:01:13,530 --> 00:01:15,740
and then it's going to again take that condition.

25
00:01:15,960 --> 00:01:21,900
And then if the condition here is again true if the Y is less than or equal to number 15 again it's

26
00:01:21,900 --> 00:01:27,610
going to actually go inside of this statement and then executed is of course OK.

27
00:01:27,780 --> 00:01:33,870
But invite loop First of all it's going to actually check the condition whether the eye is less than

28
00:01:33,870 --> 00:01:37,870
or equal to number 10 if the eye is less than or equal to number 10.

29
00:01:37,890 --> 00:01:41,870
It's going to actually execute these lines of code inside of this white loop.

30
00:01:42,060 --> 00:01:48,240
But if the eye is not less than or equal to number 10 it is not going to actually execute these lines

31
00:01:48,240 --> 00:01:48,870
of code here.

32
00:01:48,930 --> 00:01:49,500
OK.

33
00:01:49,560 --> 00:01:51,630
So here for example if we actually change.

34
00:01:51,720 --> 00:01:57,750
So here for example if we actually to change the value of this value valuable to for example number

35
00:01:58,140 --> 00:02:03,910
as 40 as you can see the value of this value variable is now 40.

36
00:02:04,200 --> 00:02:04,660
OK.

37
00:02:04,740 --> 00:02:09,900
And here I am actually checking that video is the value of the value variable is less than or equal

38
00:02:09,900 --> 00:02:10,920
to number 15.

39
00:02:11,070 --> 00:02:13,440
So let's actually run our project and see what happens.

40
00:02:13,440 --> 00:02:15,430
So now let's actually click on this.

41
00:02:15,450 --> 00:02:20,160
Start the loop button here as you can see it says the number 40.

42
00:02:20,190 --> 00:02:27,720
So OK as you can see the value of this variable is 40 and then it is actually executing these lines

43
00:02:27,720 --> 00:02:30,820
of code inside of this statement here.

44
00:02:30,870 --> 00:02:32,660
And then he's going to check the condition.

45
00:02:32,880 --> 00:02:33,640
OK.

46
00:02:33,960 --> 00:02:41,070
So hopefully that makes sense and let texturally comment out these lines of code here and let me actually

47
00:02:41,190 --> 00:02:44,890
again show you another important point about the value.

48
00:02:45,450 --> 00:02:46,260
OK.

49
00:02:46,590 --> 00:02:52,170
So as you can see here first I what we are actually creating an arm variable of type Integer.

50
00:02:52,260 --> 00:02:58,030
And then I see that you are creating a wide loop and then if are checking that the are you ready and

51
00:02:58,040 --> 00:03:02,240
the value of the variable is less than or equal to number 10.

52
00:03:02,430 --> 00:03:06,430
And that inside of this white statement you are actually putting in some lines of code.

53
00:03:06,570 --> 00:03:07,020
OK.

54
00:03:07,020 --> 00:03:13,110
So as you can see here I am actually putting this A-plus plus here and this means that after each execution

55
00:03:13,140 --> 00:03:18,730
of these of-I loop it is going to actually increase the value of the variable by 1.

56
00:03:18,870 --> 00:03:23,880
Ok so now let's let's actually comment on this line of code here and let's run that project and see

57
00:03:23,880 --> 00:03:24,550
what happens.

58
00:03:24,630 --> 00:03:28,160
So now as you can see our application is running on the emulator.

59
00:03:28,470 --> 00:03:33,050
So if I actually click on this start the loop button here.

60
00:03:33,180 --> 00:03:34,370
Let's see what happens.

61
00:03:34,410 --> 00:03:34,840
OK.

62
00:03:34,890 --> 00:03:42,110
An important point here I want to actually show you that you need to actually always consider in your

63
00:03:42,190 --> 00:03:43,960
heart in all of your projects.

64
00:03:44,040 --> 00:03:49,860
So let's just actually click on this start the loop button here as you can see nothing happened but

65
00:03:49,920 --> 00:03:55,000
it is actually doing tons of are actually calculations here.

66
00:03:55,110 --> 00:03:58,170
And then this can actually crash our application.

67
00:03:58,170 --> 00:04:00,170
So let's wait a little time.

68
00:04:00,550 --> 00:04:05,130
And as you can see here now he's going to say our application is not responding.

69
00:04:05,400 --> 00:04:11,890
And then it is going to crash and then I want to actually show you of why this crash happened.

70
00:04:11,910 --> 00:04:16,610
So as you can see here now it is an error app isn't responding.

71
00:04:16,650 --> 00:04:19,380
Do you want to close it OK.

72
00:04:20,290 --> 00:04:21,760
So the application is crashed.

73
00:04:21,820 --> 00:04:23,950
So what happened as you can see here.

74
00:04:24,220 --> 00:04:27,630
First of all I actually created a value of type Integer.

75
00:04:27,850 --> 00:04:34,270
And then here inside and then here inside of the apprentice's of this why loop I specified until the

76
00:04:34,360 --> 00:04:37,740
right is less than or equal to number 10.

77
00:04:37,780 --> 00:04:43,850
So here as you can see when I actually created this variable I assigned a value to my value but number

78
00:04:43,880 --> 00:04:44,790
zero.

79
00:04:44,860 --> 00:04:51,880
And here I am actually specifying specifying a condition in order to actually execute a while loop until

80
00:04:51,880 --> 00:04:54,490
the is less than or equal to number 10.

81
00:04:54,490 --> 00:04:57,840
So as you can see here number 0 is less than the number 10.

82
00:04:58,180 --> 00:05:04,840
And then inside of this one loop I am actually saying to the start that said text plus are two double

83
00:05:04,840 --> 00:05:05,520
quotes here.

84
00:05:05,650 --> 00:05:06,140
OK.

85
00:05:06,340 --> 00:05:13,900
And I actually commented out this line of code here and it says increase the value of this variable

86
00:05:13,900 --> 00:05:17,320
by one after each execution of this while loop.

87
00:05:17,320 --> 00:05:23,210
So now when I actually comment a commented out this line of code it is now actually the executive in

88
00:05:23,500 --> 00:05:25,490
this wild move forever.

89
00:05:25,840 --> 00:05:26,330
OK.

90
00:05:26,410 --> 00:05:32,710
It is not going to stop this why loop because we actually didn't specify what is going to happen to

91
00:05:32,710 --> 00:05:37,440
this or to the value of this variable after each execution of this while loop.

92
00:05:37,590 --> 00:05:42,880
If you are just saying until the it is less than or equal to number 10 please execute this line of code

93
00:05:42,880 --> 00:05:43,310
here.

94
00:05:43,630 --> 00:05:47,690
And that is going to actually do what we actually specify here.

95
00:05:47,950 --> 00:05:48,390
OK.

96
00:05:48,400 --> 00:05:53,040
So we need to be explicit when we actually talk to our computer.

97
00:05:53,050 --> 00:05:57,050
It is going to actually executive this line of code here forever.

98
00:05:57,320 --> 00:05:57,720
OK.

99
00:05:57,760 --> 00:06:00,780
So we need to actually put this line of code here.

100
00:06:00,910 --> 00:06:08,700
Plus plus in order to tell the computer please increase the number of the value of this valuable by

101
00:06:08,710 --> 00:06:12,490
one after each execution of this while loop.

102
00:06:12,490 --> 00:06:18,400
So hopefully that makes sense and if we actually run my project again let's see what happens.

103
00:06:18,400 --> 00:06:20,100
So now let's actually click on this.

104
00:06:20,140 --> 00:06:21,930
Start the loop button here.

105
00:06:22,300 --> 00:06:24,350
As you can see it says number 10.

106
00:06:24,400 --> 00:06:27,260
So as you can see it is actually the cutest.

107
00:06:27,350 --> 00:06:30,210
This Alwi loop ten times.

108
00:06:30,250 --> 00:06:30,990
OK.

109
00:06:31,330 --> 00:06:33,430
So hopefully that makes sense.

110
00:06:33,430 --> 00:06:39,150
So now let's actually go inside this content underline minute example and let's actually try again.

111
00:06:39,590 --> 00:06:42,500
Another actually takes you here.

112
00:06:42,550 --> 00:06:46,310
Now I want to actually show you the value of the variable.

113
00:06:46,330 --> 00:06:49,240
So after the execution of the loops.

114
00:06:49,570 --> 00:06:52,410
So let's actually double click on this component.

115
00:06:52,570 --> 00:07:01,510
So for the text I can just type in the value of pi and for ID I can just type in T S T Y.

116
00:07:02,110 --> 00:07:02,780
OK.

117
00:07:03,160 --> 00:07:10,420
So let's go back and say this main activity that Java here and now I want to actually first of all we

118
00:07:10,420 --> 00:07:17,590
need to actually create an object of this test class takes through the XTi.

119
00:07:18,040 --> 00:07:19,200
All right.

120
00:07:19,720 --> 00:07:27,250
And then I put an assignment operator here and then I need to actually cast this object to our text

121
00:07:27,250 --> 00:07:28,150
view object.

122
00:07:28,150 --> 00:07:36,840
And here I can just type in find view by id r that Id Dot T XTi by OK.

123
00:07:36,930 --> 00:07:44,940
So here as you can see decompiler I actually automatically put this final Q-Bot here in order to make

124
00:07:44,940 --> 00:07:51,100
this object a constant because it says well we actually assign a value.

125
00:07:51,510 --> 00:07:57,650
Once we actually assign a value to this at the start we cannot actually change that value.

126
00:07:57,870 --> 00:08:03,730
And it is actually right because whenever we actually refer to the name of this variable to use the

127
00:08:03,730 --> 00:08:10,770
start we are just you are just assigning a specific value to that variable at the start.

128
00:08:10,770 --> 00:08:11,990
That said text.

129
00:08:12,150 --> 00:08:19,390
Ok we cannot change this at runtime we cannot change this to another value because.

130
00:08:19,530 --> 00:08:21,470
OK because this is a constant.

131
00:08:21,480 --> 00:08:23,060
OK so hopefully that makes sense.

132
00:08:23,160 --> 00:08:25,860
So now let's actually refer to the name of this t XTi.

133
00:08:25,890 --> 00:08:30,380
I object that said text added inside the parenthesis.

134
00:08:30,390 --> 00:08:34,950
I can just refer to the name of this variable plus two double calls.

135
00:08:34,980 --> 00:08:37,530
So let's actually not project and see what happens.

136
00:08:37,530 --> 00:08:38,440
OK everyone.

137
00:08:38,490 --> 00:08:42,260
Now as you can see our application is running on this emulator.

138
00:08:42,360 --> 00:08:43,920
So let's actually click on this.

139
00:08:43,920 --> 00:08:51,710
Start the loop bottom here and as you can see here it is actually executing this way look 10 times and

140
00:08:51,710 --> 00:08:57,570
that it is actually outputting the value of this valuable to this great number 11.

141
00:08:57,660 --> 00:08:58,560
OK.

142
00:08:59,010 --> 00:09:00,690
So hopefully that makes sense.

