So this loop is going to be actually executed until the value of this response valuable is less than
the value of the lives of these people.
Ari OK.
So the length of these people rates are a the value of the length of these people rates it is 14.
OK.
These people rates rate is going to actually accept 14 integer numbers.
So after each execution of this for loop the value of this response variable is going to be incremented
by 1 OK until it reaches number 15.
OK.
So number 13 is less than 14.
OK.
So this condition evaluates to true and then is going to actually go inside of this for a loop here
and then it can actually execute this line of code here.
So people rates some number first time.
OK.
So people rates brackets.
Number 15 is number six.
OK the value that is inside of the index number 14 of these people rates are 8 is number six.
OK.
And here we have plus plus occurrence stop number six.
OK.
So we have number 6 here.
And then it's going to actually go inside of this occurrence rate.
And then it's going to go inside of the index number six of this occurrence.
So as you can see here we don't have an index number six inside these accounts occurrence.
OK.
We cannot access the value of an index that actually doesn't exist in death in that area.
That's why that our application actually crashed.
As you can see it says every index out of bounds exception lenth six index six.
OK.
So hopefully that makes sense.
And this number six is the cause of the error.
OK.
And here in order to actually catch the error and let the application actually run we can actually use
our TRY CATCH exception here.
OK.
So now that me actually comment out this line of quote here.
And remember we don't usually use try catch exceptions in are actually applications in our programs.
You have to out you have to actually consider writing your codes actually more carefully in order not
to are getting errors like this are out of bounds exception.
But for now I want to actually show you what this try catch exception is actually like.
And here I can just type in try.
OK.
And I need to open and close this try catch exception by using these curly braces.
And after this and in cold embrace of this try here I can just type in church.
OK.
An inside Apprentice's I can just type in every index out of bounds exception as you can see.
This is the type of the error that you actually get for actually accessing the value of an index that
actually doesn't exist in that array.
OK.
And we you to give our name to this error.
For example open and closed his catch statement by using these curly braces and here in say try statement
here inside the tray statement I can actually type in plus plus occurrence.
OK brackets people rates brackets respond.
OK.
If we actually put the same line of code that you actually put here and inside of the catch statement
I can actually output the informations that are actually related to this exception to the lock.
OK so I can't just type in log that's I.
OK.
At inside Apprentice's I just need to put in two double quotes.
Oh gee what a comma.
And here refers to the name of this exception here E..
That's too strange.
OK.
And I need to actually put in a semicolon at the end of my statement.
So now it's actually one of project and see what happens.
OK everyone.
Now as you can see our application is actually running on this emulator and this time fortunately our
application didn't crash.
OK.
Despite the fact that we had we have this number six in sight these people rates are.
OK.
Our application did it didn't crash because we actually used try catch here try catch statement here
in order to actually catch the error and output the description of that error to the log.
OK.
So here inside the log this local level here choose for.
OK.
And inside the search bar I can just type in L or g with capital letters.
Now as you can see we can actually see the descriptions of the error Java like that are index out of
bounds exception LeDuff 6 index 6.
So we just are here as you can see our application is run successfully and our application is actually
working right.
And we just caught the error here.
As you can see in line 49 fluid 14 free as you can see we just catch the either of type Arey index out
of bounds exception OK instead of just actually writing an hourly index out of an exception I could
I could just type an exception exception.
OK.
And in this way we could actually get the descriptions about the error so let's actually do it on our
project.
So as you can see here our application is actually unique on this emulator.
And again we can see the descriptions of of this error here inside the lock.
OK.
So by using Truscott's statement we actually can catch the errors but this is not the right way to actually
write our own code.
OK.
We should actually write code in a way that is actually completely perfect and cannot actually result
in an error.
OK.
And here I just wanted to show you how you can actually use Tractate statement in order to actually
output the descriptions of those errors to their log.
OK.
So I think that's enough for this theater the.
And if you have any questions please post the discussion in the course and I'll do my best to answer
all of your questions.
Thank you very much for watching and I'll see you in the next year to Hollywood.