So now let's actually click on this.
Start of the loop button here.
As you can see it says 15.
OK.
So it is actually executing this up do I do 15 times.
So what's the difference between a loop and a do while loop the loop.
You're actually sure that it's going to actually first of all specify that whether this condition is
true or not until it is less than or equal to number 10.
And then it can actually go inside this y loop and then it's going to execute these lines of code.
Here for example.
But do a loop First of all it can actually do these lines of code inside of these curly braces.
OK.
First it's going to actually do these lines of code and then it's going to check the condition.
Why.
Why is less than or equal to number 15.
So in Duvel loop you are sure that your codes inside the DO statement is going to be executed at least
once.
OK.
And then it can actually check the condition.
OK.
First it's going to do these lines of code and then it's going to check the condition.
And then again it's going actually.
And then if the condition is true it is going to again do these lines of code inside of these two statements
and then it's going to again take that condition.
And then if the condition here is again true if the Y is less than or equal to number 15 again it's
going to actually go inside of this statement and then executed is of course OK.
But invite loop First of all it's going to actually check the condition whether the eye is less than
or equal to number 10 if the eye is less than or equal to number 10.
It's going to actually execute these lines of code inside of this white loop.
But if the eye is not less than or equal to number 10 it is not going to actually execute these lines
of code here.
OK.
So here for example if we actually change.
So here for example if we actually to change the value of this value valuable to for example number
as 40 as you can see the value of this value variable is now 40.
OK.
And here I am actually checking that video is the value of the value variable is less than or equal
to number 15.
So let's actually run our project and see what happens.
So now let's actually click on this.
Start the loop button here as you can see it says the number 40.
So OK as you can see the value of this variable is 40 and then it is actually executing these lines
of code inside of this statement here.
And then he's going to check the condition.
OK.
So hopefully that makes sense and let texturally comment out these lines of code here and let me actually
again show you another important point about the value.
OK.
So as you can see here first I what we are actually creating an arm variable of type Integer.
And then I see that you are creating a wide loop and then if are checking that the are you ready and
the value of the variable is less than or equal to number 10.
And that inside of this white statement you are actually putting in some lines of code.
OK.
So as you can see here I am actually putting this A-plus plus here and this means that after each execution
of these of-I loop it is going to actually increase the value of the variable by 1.
Ok so now let's let's actually comment on this line of code here and let's run that project and see
what happens.
So now as you can see our application is running on the emulator.
So if I actually click on this start the loop button here.
Let's see what happens.
OK.
An important point here I want to actually show you that you need to actually always consider in your
heart in all of your projects.
So let's just actually click on this start the loop button here as you can see nothing happened but
it is actually doing tons of are actually calculations here.
And then this can actually crash our application.
So let's wait a little time.
And as you can see here now he's going to say our application is not responding.
And then it is going to crash and then I want to actually show you of why this crash happened.
So as you can see here now it is an error app isn't responding.
Do you want to close it OK.
So the application is crashed.
So what happened as you can see here.
First of all I actually created a value of type Integer.
And then here inside and then here inside of the apprentice's of this why loop I specified until the
right is less than or equal to number 10.
So here as you can see when I actually created this variable I assigned a value to my value but number
zero.
And here I am actually specifying specifying a condition in order to actually execute a while loop until
the is less than or equal to number 10.
So as you can see here number 0 is less than the number 10.
And then inside of this one loop I am actually saying to the start that said text plus are two double
quotes here.
OK.
And I actually commented out this line of code here and it says increase the value of this variable
by one after each execution of this while loop.
So now when I actually comment a commented out this line of code it is now actually the executive in
this wild move forever.
OK.
It is not going to stop this why loop because we actually didn't specify what is going to happen to
this or to the value of this variable after each execution of this while loop.
If you are just saying until the it is less than or equal to number 10 please execute this line of code
here.
And that is going to actually do what we actually specify here.
OK.
So we need to be explicit when we actually talk to our computer.
It is going to actually executive this line of code here forever.
OK.
So we need to actually put this line of code here.
Plus plus in order to tell the computer please increase the number of the value of this valuable by
one after each execution of this while loop.
So hopefully that makes sense and if we actually run my project again let's see what happens.
So now let's actually click on this.
Start the loop button here.
As you can see it says number 10.
So as you can see it is actually the cutest.
This Alwi loop ten times.
OK.
So hopefully that makes sense.
So now let's actually go inside this content underline minute example and let's actually try again.
Another actually takes you here.
Now I want to actually show you the value of the variable.
So after the execution of the loops.
So let's actually double click on this component.
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.
OK.
So let's go back and say this main activity that Java here and now I want to actually first of all we
need to actually create an object of this test class takes through the XTi.
All right.
And then I put an assignment operator here and then I need to actually cast this object to our text
view object.
And here I can just type in find view by id r that Id Dot T XTi by OK.
So here as you can see decompiler I actually automatically put this final Q-Bot here in order to make
this object a constant because it says well we actually assign a value.
Once we actually assign a value to this at the start we cannot actually change that value.
And it is actually right because whenever we actually refer to the name of this variable to use the
start we are just you are just assigning a specific value to that variable at the start.
That said text.
Ok we cannot change this at runtime we cannot change this to another value because.
OK because this is a constant.
OK so hopefully that makes sense.
So now let's actually refer to the name of this t XTi.
I object that said text added inside the parenthesis.
I can just refer to the name of this variable plus two double calls.
So let's actually not project and see what happens.
OK everyone.
Now as you can see our application is running on this emulator.
So let's actually click on this.
Start the loop bottom here and as you can see here it is actually executing this way look 10 times and
that it is actually outputting the value of this valuable to this great number 11.
OK.
So hopefully that makes sense.