1
00:00:00,140 --> 00:00:06,570
So this loop is going to be actually executed until the value of this response valuable is less than

2
00:00:06,960 --> 00:00:09,210
the value of the lives of these people.

3
00:00:09,300 --> 00:00:10,420
Ari OK.

4
00:00:10,890 --> 00:00:15,770
So the length of these people rates are a the value of the length of these people rates it is 14.

5
00:00:15,810 --> 00:00:16,260
OK.

6
00:00:16,260 --> 00:00:20,430
These people rates rate is going to actually accept 14 integer numbers.

7
00:00:20,430 --> 00:00:27,290
So after each execution of this for loop the value of this response variable is going to be incremented

8
00:00:27,300 --> 00:00:31,400
by 1 OK until it reaches number 15.

9
00:00:31,650 --> 00:00:32,050
OK.

10
00:00:32,070 --> 00:00:33,780
So number 13 is less than 14.

11
00:00:33,780 --> 00:00:34,160
OK.

12
00:00:34,230 --> 00:00:39,410
So this condition evaluates to true and then is going to actually go inside of this for a loop here

13
00:00:39,960 --> 00:00:42,240
and then it can actually execute this line of code here.

14
00:00:42,270 --> 00:00:44,350
So people rates some number first time.

15
00:00:44,370 --> 00:00:45,100
OK.

16
00:00:45,120 --> 00:00:46,680
So people rates brackets.

17
00:00:46,710 --> 00:00:49,460
Number 15 is number six.

18
00:00:49,470 --> 00:00:56,440
OK the value that is inside of the index number 14 of these people rates are 8 is number six.

19
00:00:56,460 --> 00:00:56,940
OK.

20
00:00:57,120 --> 00:01:01,520
And here we have plus plus occurrence stop number six.

21
00:01:01,590 --> 00:01:02,410
OK.

22
00:01:02,580 --> 00:01:05,110
So we have number 6 here.

23
00:01:05,880 --> 00:01:09,350
And then it's going to actually go inside of this occurrence rate.

24
00:01:09,690 --> 00:01:14,650
And then it's going to go inside of the index number six of this occurrence.

25
00:01:14,880 --> 00:01:20,840
So as you can see here we don't have an index number six inside these accounts occurrence.

26
00:01:21,170 --> 00:01:21,600
OK.

27
00:01:21,660 --> 00:01:27,670
We cannot access the value of an index that actually doesn't exist in death in that area.

28
00:01:27,690 --> 00:01:30,900
That's why that our application actually crashed.

29
00:01:31,140 --> 00:01:37,110
As you can see it says every index out of bounds exception lenth six index six.

30
00:01:37,290 --> 00:01:38,850
OK.

31
00:01:39,180 --> 00:01:40,590
So hopefully that makes sense.

32
00:01:40,620 --> 00:01:43,160
And this number six is the cause of the error.

33
00:01:43,170 --> 00:01:43,570
OK.

34
00:01:43,620 --> 00:01:49,050
And here in order to actually catch the error and let the application actually run we can actually use

35
00:01:49,320 --> 00:01:51,620
our TRY CATCH exception here.

36
00:01:51,650 --> 00:01:52,350
OK.

37
00:01:52,860 --> 00:01:56,600
So now that me actually comment out this line of quote here.

38
00:01:56,730 --> 00:02:04,800
And remember we don't usually use try catch exceptions in are actually applications in our programs.

39
00:02:04,800 --> 00:02:10,710
You have to out you have to actually consider writing your codes actually more carefully in order not

40
00:02:10,710 --> 00:02:14,440
to are getting errors like this are out of bounds exception.

41
00:02:14,490 --> 00:02:19,210
But for now I want to actually show you what this try catch exception is actually like.

42
00:02:19,410 --> 00:02:21,650
And here I can just type in try.

43
00:02:21,770 --> 00:02:22,620
OK.

44
00:02:22,830 --> 00:02:27,300
And I need to open and close this try catch exception by using these curly braces.

45
00:02:27,450 --> 00:02:33,760
And after this and in cold embrace of this try here I can just type in church.

46
00:02:34,130 --> 00:02:34,710
OK.

47
00:02:34,850 --> 00:02:41,840
An inside Apprentice's I can just type in every index out of bounds exception as you can see.

48
00:02:41,940 --> 00:02:48,630
This is the type of the error that you actually get for actually accessing the value of an index that

49
00:02:48,660 --> 00:02:51,130
actually doesn't exist in that array.

50
00:02:51,240 --> 00:02:51,630
OK.

51
00:02:51,630 --> 00:02:54,350
And we you to give our name to this error.

52
00:02:54,630 --> 00:03:02,640
For example open and closed his catch statement by using these curly braces and here in say try statement

53
00:03:02,730 --> 00:03:08,800
here inside the tray statement I can actually type in plus plus occurrence.

54
00:03:09,070 --> 00:03:15,750
OK brackets people rates brackets respond.

55
00:03:16,090 --> 00:03:16,970
OK.

56
00:03:17,080 --> 00:03:22,200
If we actually put the same line of code that you actually put here and inside of the catch statement

57
00:03:22,810 --> 00:03:28,940
I can actually output the informations that are actually related to this exception to the lock.

58
00:03:28,980 --> 00:03:32,800
OK so I can't just type in log that's I.

59
00:03:33,350 --> 00:03:34,170
OK.

60
00:03:34,210 --> 00:03:37,860
At inside Apprentice's I just need to put in two double quotes.

61
00:03:38,000 --> 00:03:40,560
Oh gee what a comma.

62
00:03:41,040 --> 00:03:44,290
And here refers to the name of this exception here E..

63
00:03:44,830 --> 00:03:47,200
That's too strange.

64
00:03:47,450 --> 00:03:48,270
OK.

65
00:03:48,630 --> 00:03:51,820
And I need to actually put in a semicolon at the end of my statement.

66
00:03:51,840 --> 00:03:55,680
So now it's actually one of project and see what happens.

67
00:03:55,770 --> 00:03:56,820
OK everyone.

68
00:03:56,820 --> 00:04:04,500
Now as you can see our application is actually running on this emulator and this time fortunately our

69
00:04:04,500 --> 00:04:06,010
application didn't crash.

70
00:04:06,030 --> 00:04:06,360
OK.

71
00:04:06,390 --> 00:04:12,010
Despite the fact that we had we have this number six in sight these people rates are.

72
00:04:12,260 --> 00:04:12,840
OK.

73
00:04:13,080 --> 00:04:20,010
Our application did it didn't crash because we actually used try catch here try catch statement here

74
00:04:20,400 --> 00:04:26,050
in order to actually catch the error and output the description of that error to the log.

75
00:04:26,160 --> 00:04:26,930
OK.

76
00:04:27,150 --> 00:04:31,680
So here inside the log this local level here choose for.

77
00:04:31,860 --> 00:04:32,290
OK.

78
00:04:32,370 --> 00:04:37,790
And inside the search bar I can just type in L or g with capital letters.

79
00:04:37,800 --> 00:04:43,950
Now as you can see we can actually see the descriptions of the error Java like that are index out of

80
00:04:43,950 --> 00:04:47,250
bounds exception LeDuff 6 index 6.

81
00:04:47,430 --> 00:04:52,830
So we just are here as you can see our application is run successfully and our application is actually

82
00:04:52,830 --> 00:04:53,680
working right.

83
00:04:53,710 --> 00:04:55,380
And we just caught the error here.

84
00:04:55,530 --> 00:05:02,420
As you can see in line 49 fluid 14 free as you can see we just catch the either of type Arey index out

85
00:05:02,420 --> 00:05:08,090
of bounds exception OK instead of just actually writing an hourly index out of an exception I could

86
00:05:08,170 --> 00:05:11,060
I could just type an exception exception.

87
00:05:11,300 --> 00:05:11,810
OK.

88
00:05:11,930 --> 00:05:16,640
And in this way we could actually get the descriptions about the error so let's actually do it on our

89
00:05:16,640 --> 00:05:17,330
project.

90
00:05:17,330 --> 00:05:21,370
So as you can see here our application is actually unique on this emulator.

91
00:05:21,380 --> 00:05:26,300
And again we can see the descriptions of of this error here inside the lock.

92
00:05:26,390 --> 00:05:27,370
OK.

93
00:05:27,620 --> 00:05:34,670
So by using Truscott's statement we actually can catch the errors but this is not the right way to actually

94
00:05:34,670 --> 00:05:35,670
write our own code.

95
00:05:35,690 --> 00:05:36,180
OK.

96
00:05:36,320 --> 00:05:44,330
We should actually write code in a way that is actually completely perfect and cannot actually result

97
00:05:44,480 --> 00:05:45,010
in an error.

98
00:05:45,020 --> 00:05:45,460
OK.

99
00:05:45,500 --> 00:05:50,660
And here I just wanted to show you how you can actually use Tractate statement in order to actually

100
00:05:50,930 --> 00:05:53,720
output the descriptions of those errors to their log.

101
00:05:53,780 --> 00:05:54,240
OK.

102
00:05:54,380 --> 00:05:57,350
So I think that's enough for this theater the.

103
00:05:57,560 --> 00:06:02,930
And if you have any questions please post the discussion in the course and I'll do my best to answer

104
00:06:02,990 --> 00:06:04,460
all of your questions.

105
00:06:04,460 --> 00:06:08,460
Thank you very much for watching and I'll see you in the next year to Hollywood.

