1
00:00:00,230 --> 00:00:06,360
Higher level as you may already know our application actually has it but so what is this bug.

2
00:00:06,390 --> 00:00:08,510
Let's actually look at this smartphone computer.

3
00:00:08,640 --> 00:00:13,250
You can see that the name of this smartphone computer is actually the iPad.

4
00:00:13,470 --> 00:00:14,180
Right.

5
00:00:14,190 --> 00:00:16,670
So let's go back to android studio.

6
00:00:16,740 --> 00:00:20,660
That makes you double click on the main activity that Java tap in order to make this area wider.

7
00:00:20,850 --> 00:00:26,700
So Enceladus main activity class and inside these uncreate Smurfette you can see that when we created

8
00:00:26,970 --> 00:00:29,850
this object of type smartphone computer.

9
00:00:29,850 --> 00:00:35,260
So here let me tell you that here we are creating a variable of type smartphone computer right.

10
00:00:35,280 --> 00:00:40,380
So this is the data type and this is the name of Aradia But after this assignment operator you can see

11
00:00:40,380 --> 00:00:47,010
that you're saying new smartphone computers so here we are actually creating the actual object of type

12
00:00:47,290 --> 00:00:49,120
actually that smart computer.

13
00:00:49,440 --> 00:00:55,650
And we are assigning the actual object of type Smarthome computer to this valuable type smartphone computer

14
00:00:55,740 --> 00:00:57,970
and the name of this variable is a smartphone computer.

15
00:00:58,110 --> 00:01:00,070
So look at this object here.

16
00:01:00,090 --> 00:01:02,850
Here we see that the name is iPhone 6 s.

17
00:01:02,910 --> 00:01:04,400
So let me show the emulator.

18
00:01:04,440 --> 00:01:05,780
It says The name is i-Pad.

19
00:01:05,790 --> 00:01:06,430
Why.

20
00:01:06,450 --> 00:01:09,840
It is actually outputting the value of this tablet computer.

21
00:01:09,830 --> 00:01:12,220
The name of this tablet computer to this screen.

22
00:01:12,270 --> 00:01:16,040
Not the name of this actually sponsored computer which is iPhone 6.

23
00:01:16,210 --> 00:01:25,600
These six actually or you can see that for example the type of the keyboard is actually a virtual keyboard.

24
00:01:25,620 --> 00:01:29,860
I actually forgot to put r here but you can see that here.

25
00:01:30,150 --> 00:01:32,850
You can't actually see this value here.

26
00:01:32,850 --> 00:01:34,540
So it is actually overlaid.

27
00:01:34,550 --> 00:01:38,820
In other words it is overwriting the values of these smartphone computers.

28
00:01:38,820 --> 00:01:41,850
So let me actually correct this value here.

29
00:01:41,880 --> 00:01:44,860
Now I'm going to actually tell you why.

30
00:01:45,020 --> 00:01:49,540
First I want to actually let you know about debugging in Android.

31
00:01:49,580 --> 00:01:53,480
So in order to actually debug that application we need to use the break point.

32
00:01:53,480 --> 00:01:55,340
So what is a breakpoint here.

33
00:01:55,400 --> 00:02:02,630
A breakpoint is actually a little red circle that we put here inside this a left side bar here inside

34
00:02:02,670 --> 00:02:05,090
is actually a gray area here.

35
00:02:05,330 --> 00:02:11,900
So look at this line of code here in line number 42 and go inside the left sidebar in line number 42

36
00:02:11,930 --> 00:02:15,950
and just click on it and now you can see that we have this letter actually read.

37
00:02:15,950 --> 00:02:18,490
This little red circle here.

38
00:02:18,590 --> 00:02:22,150
So this is actually Bridgeport.

39
00:02:22,160 --> 00:02:28,070
So this means that we had to stop the flow of the application we are going to stop the execution of

40
00:02:28,070 --> 00:02:31,360
the application from this line of code here.

41
00:02:31,370 --> 00:02:37,240
So in this way we are going to control the flow of the application that the execution of the application.

42
00:02:37,490 --> 00:02:41,270
So now at the top menu here you can see that we have this option.

43
00:02:41,270 --> 00:02:45,370
It says debug app right and then click click on it.

44
00:02:45,380 --> 00:02:50,880
Just click on it and it's going to show you this message it says lunching at to switch from run to debug.

45
00:02:50,900 --> 00:02:52,160
The app has to restart.

46
00:02:52,160 --> 00:02:59,790
Continue yes click on restart app and then choose an emulator here and then click on OK let's wait a

47
00:02:59,790 --> 00:03:02,120
little bit here.

48
00:03:02,230 --> 00:03:07,320
So now you can see that our application is actually into the debug mode here.

49
00:03:07,510 --> 00:03:10,530
Now let's see actually what's going on here.

50
00:03:10,540 --> 00:03:13,220
Let me show you the line number first the two here.

51
00:03:13,330 --> 00:03:17,890
So now here we have actually you can see this de-bug area.

52
00:03:17,950 --> 00:03:18,910
We have some options.

53
00:03:18,910 --> 00:03:22,970
The first one is actually this button that says step over.

54
00:03:23,110 --> 00:03:26,580
The second option the second button actually is step into.

55
00:03:26,590 --> 00:03:27,550
Right.

56
00:03:27,790 --> 00:03:34,210
So now let's for example if we actually click on this step into it's going to go inside the execution

57
00:03:34,210 --> 00:03:39,640
it's going to go inside the constructor of this smart phone computer class and it's going to actually

58
00:03:39,670 --> 00:03:41,050
assign these values.

59
00:03:41,050 --> 00:03:46,810
For example the name the type of the screen the type of the keyboard and the operating system and all

60
00:03:46,810 --> 00:03:48,300
the others other values.

61
00:03:48,310 --> 00:03:52,420
So let's click on this that into in order to see what happens.

62
00:03:52,420 --> 00:03:57,370
So as you can see it actually went into the smartphone computer constructed inside this Mathman computer

63
00:03:57,370 --> 00:04:01,380
class and the first line that is going to be executed is this one.

64
00:04:01,540 --> 00:04:02,580
So we have another.

65
00:04:02,620 --> 00:04:04,270
The button insists that over.

66
00:04:04,270 --> 00:04:05,740
So what does that over do.

67
00:04:05,800 --> 00:04:10,110
This that over is going to actually execute this line of code in its entirety.

68
00:04:10,300 --> 00:04:10,790
Right.

69
00:04:10,800 --> 00:04:15,580
Sort of step into it can actually go into the declare it into the declaration of the constructor.

70
00:04:15,670 --> 00:04:17,740
Or of a specific method.

71
00:04:17,740 --> 00:04:23,130
But step over is going to actually execute that's a line of code in its entirety.

72
00:04:23,140 --> 00:04:28,120
So let's actually click on the step over button here and let's see what happens.

73
00:04:28,120 --> 00:04:32,440
So now as you can see this line of code is actually executed in its entirety.

74
00:04:32,440 --> 00:04:34,110
This means that the name is passed.

75
00:04:34,180 --> 00:04:38,920
The screen is passed and the keyboard is passed to the constructor of the superclass which is going

76
00:04:38,920 --> 00:04:40,310
to be the computer class.

77
00:04:40,330 --> 00:04:43,830
Right now it's actually highlighting this constructor again.

78
00:04:43,840 --> 00:04:45,380
Let's click on this.

79
00:04:45,580 --> 00:04:46,870
Step over button again.

80
00:04:46,930 --> 00:04:52,230
So now it's going to execute this statement is going to actually see if the power that is passed to

81
00:04:52,310 --> 00:04:55,830
is constructed is actually less than or equal to zero or not.

82
00:04:55,840 --> 00:04:58,860
So the C.P.R. power that is passed is actually the 500.

83
00:04:58,870 --> 00:05:03,300
If I could hover over to if you power it has Sebille power is 500.

84
00:05:03,310 --> 00:05:04,950
And let me show you the emulator.

85
00:05:05,380 --> 00:05:06,480
So here.

86
00:05:06,670 --> 00:05:10,570
It's not going to show us the value because we are in the debugging mode.

87
00:05:10,600 --> 00:05:13,490
We need to actually go into the smartphone computer.

88
00:05:13,510 --> 00:05:17,980
We need to go into that main activity class actually and inside this uncreate Meffert we need to look

89
00:05:17,980 --> 00:05:24,550
at this much smarter computer construct that we can see that the value of the Sibiu power that is passed

90
00:05:24,550 --> 00:05:25,860
is actually 500.

91
00:05:25,990 --> 00:05:26,530
Right.

92
00:05:26,530 --> 00:05:30,430
So let's go back to smartphone computer so we can see this value here.

93
00:05:30,430 --> 00:05:33,010
So this a solution here evaluates to false.

94
00:05:33,010 --> 00:05:36,070
This means that this statement here is not going to it's not going to be executed.

95
00:05:36,190 --> 00:05:41,460
And as a result this exception here is not going to be actually up front.

96
00:05:41,710 --> 00:05:48,190
So let's click on this so that over again as you can see this statement is not executed because the

97
00:05:48,190 --> 00:05:55,400
Sibiu power is great is actually greater than zero here and we have the ram.

98
00:05:55,420 --> 00:05:58,230
So let's actually look at the value of the Ram.

99
00:05:58,390 --> 00:06:01,700
Let's click on this that over.

100
00:06:01,750 --> 00:06:08,180
If we actually show it here the value of these tablets actually hovered over this and I'm here and you

101
00:06:08,180 --> 00:06:15,240
can see that the value of the ramp is actually not actually less than or equal to zero.

102
00:06:15,260 --> 00:06:16,130
Right.

103
00:06:16,130 --> 00:06:19,110
So now it's going to execute this line of code here the operating system.

104
00:06:19,340 --> 00:06:24,200
So now it's just highlighting this line of code and this means that this line of code is about to be

105
00:06:24,200 --> 00:06:24,800
executed.

106
00:06:24,800 --> 00:06:28,940
So that's why you can see that it says the operating system now is not.

107
00:06:29,020 --> 00:06:30,460
Let's step over.

108
00:06:30,500 --> 00:06:33,790
In order to execute this line of code in its entirety.

109
00:06:33,860 --> 00:06:36,810
So now you can see that the operating system is IOAS.

110
00:06:36,810 --> 00:06:37,190
Why.

111
00:06:37,190 --> 00:06:39,770
Because this line of code is now executed.

112
00:06:39,770 --> 00:06:43,630
Right now it's about to execute this thing and I've got here subpoena power.

113
00:06:43,730 --> 00:06:45,350
Now it is actually zero.

114
00:06:45,530 --> 00:06:50,570
If we actually execute isn't enough what is going to assign 500 to the CPO power instance variable.

115
00:06:50,750 --> 00:06:52,620
Let's click on this is that over.

116
00:06:52,760 --> 00:06:58,100
Now we can see that the spew poverty's 500 here and now it's about to execute this line of code.

117
00:06:58,110 --> 00:06:59,780
Now Ram is 0 right.

118
00:06:59,960 --> 00:07:02,890
Let's click on this that over to execute this line of code here.

119
00:07:04,940 --> 00:07:06,580
Let me actually click on that over.

120
00:07:06,650 --> 00:07:09,430
So now we can see that the van is 400.

121
00:07:09,620 --> 00:07:10,610
Right.

122
00:07:10,760 --> 00:07:15,560
So this line of code is also executed and now it actually reached to this end in the curly braces is

123
00:07:15,560 --> 00:07:16,160
constructed.

124
00:07:16,160 --> 00:07:20,600
If I click on this step over it again it's going to go back to the main activity class and it's going

125
00:07:20,600 --> 00:07:22,570
to highlight that line first to exit.

126
00:07:22,610 --> 00:07:27,520
You know that will actually allow us to execute that line of code in it's in it's actually entirety.

127
00:07:27,530 --> 00:07:29,850
Let's step over.

128
00:07:29,880 --> 00:07:34,910
So now you can see that this line of code here is actually executed in its entirety.

129
00:07:35,100 --> 00:07:38,970
And now it's about to execute this line of that tablet computer right.

130
00:07:38,970 --> 00:07:43,600
So in the debugging mode you are actually in complete control of the execution of the program.

131
00:07:43,600 --> 00:07:48,390
We can't completely control the flow of the program that which line of code is actually executed at

132
00:07:48,390 --> 00:07:49,530
the moment.

133
00:07:49,530 --> 00:07:52,800
So this line of code is executed and these values are passed.

134
00:07:52,860 --> 00:07:55,760
So now it's about to execute this line of code tablet computer.

135
00:07:55,950 --> 00:08:02,010
Let's actually look at these values that I is the name resinous screen virtual keyboard Iowas and these

136
00:08:02,020 --> 00:08:02,900
values right.

137
00:08:02,910 --> 00:08:09,170
If I click on this step over we can see that this line of code is actually executed in its entirety.

138
00:08:09,210 --> 00:08:14,970
But if I actually wanted to look at the constructed of the tablet computer class and if I wanted to

139
00:08:15,090 --> 00:08:22,370
see how that constructed is actually executed I needed to click on this step into right instead of step

140
00:08:22,370 --> 00:08:22,810
over.

141
00:08:22,930 --> 00:08:26,370
So now it's going to introduce a new design of got here.

142
00:08:26,760 --> 00:08:31,770
So the problem of our application is not actually related to the performance because the problem is

143
00:08:31,770 --> 00:08:38,490
actually related to the smartphone computer and the values of the tablet computer is actually overriding

144
00:08:38,490 --> 00:08:44,340
the values of our smartphone computer so we need to solve that so we don't have to actually be worried

145
00:08:44,340 --> 00:08:48,020
about these lines of code that are related to the performance.

146
00:08:48,020 --> 00:08:52,220
So I just need to click on this that over here multiple times in order to execute these lines of code

147
00:08:52,720 --> 00:08:54,090
in their entirety.

148
00:08:54,240 --> 00:08:56,860
And now let's actually look at this at 8.

149
00:08:56,880 --> 00:08:57,690
This is very important.

150
00:08:57,690 --> 00:09:02,700
The problem is here actually so here we have an array of computer objects.

151
00:09:02,700 --> 00:09:03,110
Right.

152
00:09:03,120 --> 00:09:07,180
So here we actually specify the size of this area which is going to be four.

153
00:09:07,190 --> 00:09:11,700
This means that these are it can only accept four objects of type computer.

154
00:09:11,700 --> 00:09:12,170
Right.

155
00:09:12,450 --> 00:09:13,830
Let's click on this.

156
00:09:13,890 --> 00:09:18,510
Step over in order to execute this line of code in its entirety so you can see that we have an array

157
00:09:18,810 --> 00:09:26,700
of objects and we haven't still initialized this out if we just specify that this area can hold for

158
00:09:26,730 --> 00:09:27,380
objects.

159
00:09:27,480 --> 00:09:30,150
It's going to secure this line of code now in line number 44.

160
00:09:30,150 --> 00:09:35,070
We are going to assign in the index zero of this at a the value of this desktop computer right let's

161
00:09:35,070 --> 00:09:35,860
click on it.

162
00:09:35,880 --> 00:09:40,770
So now that this computer is assigned in the index zero of these computers at it you can see this value

163
00:09:40,770 --> 00:09:41,030
here.

164
00:09:41,070 --> 00:09:45,180
This computer right now it's going to include this line of quote.

165
00:09:45,290 --> 00:09:47,810
Laptop computer is going to be assigned into the index.

166
00:09:47,810 --> 00:09:49,390
One of these computers at.

167
00:09:49,430 --> 00:09:50,730
Let's click on this.

168
00:09:50,780 --> 00:09:55,530
Step over it in order to execute this line of code in its entirety so you can see the value here.

169
00:09:55,790 --> 00:10:00,340
Right now it's about to execute this line of code here in line number 46.

170
00:10:00,410 --> 00:10:06,860
It's going to assign the value of this smartphone computer to the index number two of these computers

171
00:10:06,920 --> 00:10:07,450
at a.

172
00:10:07,610 --> 00:10:08,600
Let's click on this.

173
00:10:08,610 --> 00:10:10,510
Step over.

174
00:10:10,690 --> 00:10:15,700
Now you can see that the smartphone computer is actually assigned into their index number to of this

175
00:10:15,700 --> 00:10:16,320
computer.

176
00:10:16,360 --> 00:10:20,850
And now finally we have the tablet computer which is going to be assigned to the index number three

177
00:10:20,860 --> 00:10:23,170
of these computers and let's get to kind of step over.

178
00:10:23,170 --> 00:10:25,840
So now these lines of code are actually executed.

179
00:10:25,900 --> 00:10:29,980
So look at this for this enhanced for loop here.

180
00:10:29,980 --> 00:10:32,460
The problem is actually occurring here.

181
00:10:32,560 --> 00:10:38,170
So now it's going to actually look at this array and it's going on just for example.

182
00:10:38,170 --> 00:10:42,430
See that it's going to iterate over all of the computer objects.

183
00:10:42,430 --> 00:10:46,870
For example the desktop computer a laptop computer a smartphone computer or a tablet computer.

184
00:10:46,930 --> 00:10:51,310
It's going to iterate over all these objects and it's going to actually look at these conditions and

185
00:10:51,310 --> 00:10:56,520
it's good to see what each one of these conditions are met and it's going to execute those if statements.

186
00:10:56,530 --> 00:11:01,510
So the first computer object that is inside of these computers is actually a supercomputer.

187
00:11:01,510 --> 00:11:09,420
So remember arrays are actually on an ordered collection of values that this means that the order matters.

188
00:11:09,550 --> 00:11:10,170
Right.

189
00:11:10,210 --> 00:11:16,660
When we assign this computer into the index 0 this means that this computer is the first computer inside

190
00:11:16,660 --> 00:11:17,210
the site.

191
00:11:17,500 --> 00:11:24,240
So it is going to actually execute when it is going to actually execute these enhanced for loop.

192
00:11:24,700 --> 00:11:30,030
The first computer Optik is actually there's that computer you are completely sure about that.

193
00:11:30,040 --> 00:11:31,420
So let's click on this.

194
00:11:31,420 --> 00:11:33,000
Step over.

195
00:11:33,140 --> 00:11:33,940
So just click on.

196
00:11:33,970 --> 00:11:34,790
Step over.

197
00:11:34,930 --> 00:11:39,070
And now it can actually execute this statement inside this enhanced for loop.

198
00:11:39,340 --> 00:11:44,990
So the first object is this computer right so it can actually look at this computer variable here.

199
00:11:45,100 --> 00:11:49,560
So you know that this is going to be executed for each object inside these computers.

200
00:11:49,690 --> 00:11:51,130
The first one is this computer.

201
00:11:51,130 --> 00:11:55,580
So it's going to look at this object is value but that holds the first object and say this computer's

202
00:11:55,580 --> 00:12:03,240
Ali is going to see that OK if this computer object is actually an instance of type desktop computer

203
00:12:03,310 --> 00:12:08,400
this instance of means that this computer is actually type this computer.

204
00:12:08,430 --> 00:12:15,230
So it is actually right because this computer we have this desktop computer instance right.

205
00:12:15,270 --> 00:12:19,820
It is actually the desktop computer so this condition here this expression evaluates to true.

206
00:12:20,020 --> 00:12:23,320
And it's going to execute the lines of code inside this statement.

207
00:12:23,350 --> 00:12:24,360
So let's click on this.

208
00:12:24,370 --> 00:12:29,560
Step forward in order to execute this statement let's click on it and now we can see that this condition

209
00:12:29,560 --> 00:12:30,230
is met.

210
00:12:30,250 --> 00:12:32,580
This is the second version is actually true.

211
00:12:32,680 --> 00:12:35,470
So now it went into the curly braces of this statement.

212
00:12:35,590 --> 00:12:38,040
So he's going to ask you this then I've put in a number of the free.

213
00:12:38,200 --> 00:12:39,110
Let's click on this.

214
00:12:39,130 --> 00:12:40,540
Step over.

215
00:12:40,540 --> 00:12:45,820
Now you can see that it's going to say that it's going to output.

216
00:12:45,900 --> 00:12:49,000
It's going to create this object here let's can't step over.

217
00:12:49,000 --> 00:12:53,080
So it's going to get this object which is like this a computer and it is completely correct.

218
00:12:53,080 --> 00:12:56,980
Calling this the computer and it's going to output this value to the screen.

219
00:12:57,000 --> 00:13:02,770
This THC this computer that's set text cut into this computer that was three in is going to call the

220
00:13:02,770 --> 00:13:04,960
twisting of the candidates the computer.

221
00:13:04,960 --> 00:13:06,120
Let's go step over.

222
00:13:06,210 --> 00:13:09,430
Now is it actually executed this line of code.

223
00:13:09,550 --> 00:13:12,910
So now it's going to actually look at this condition here.

224
00:13:12,940 --> 00:13:19,170
If the computer is actually an instance of laptop computer so desktop computer is not an instance of

225
00:13:19,180 --> 00:13:20,420
laptop computer wide.

226
00:13:20,440 --> 00:13:26,380
So let's go into the computer class here and you can see that the desktop computer is actually an instance

227
00:13:26,380 --> 00:13:30,310
of computer class not actually a laptop computer.

228
00:13:30,310 --> 00:13:35,770
So let's actually go back to the main activity class so here then it's his computer which is actually

229
00:13:35,770 --> 00:13:38,610
a desktop computer is instance of laptop computer.

230
00:13:38,620 --> 00:13:41,080
This expression he had evaluates to false.

231
00:13:41,260 --> 00:13:43,960
So it's not going to actually execute this line of code here.

232
00:13:44,020 --> 00:13:44,410
Right.

233
00:13:44,410 --> 00:13:46,480
It's not going to execute this statement this if.

234
00:13:46,500 --> 00:13:48,990
He is actually going to be skipped.

235
00:13:49,180 --> 00:13:50,580
Let's step over.

236
00:13:50,650 --> 00:13:53,240
So now you can see that this statement is actually skewed.

237
00:13:53,290 --> 00:13:55,920
So nice going to do look at this if statement here.

238
00:13:56,050 --> 00:14:00,190
If the computer which is actually this that computer is an instance of a smartphone or a computer.

239
00:14:00,190 --> 00:14:02,410
So again this explosion evaluates to false.

240
00:14:02,560 --> 00:14:04,120
Let's step over.

241
00:14:04,150 --> 00:14:09,070
Now you can see that this statement here is actually skipped and it's going to finally look at this.

242
00:14:09,220 --> 00:14:10,750
This statement here.

243
00:14:10,750 --> 00:14:14,230
So it's going to say that if the computer is an instance of tablet computer.

244
00:14:14,230 --> 00:14:19,370
So again this expedition evaluates to false because this computer is not actually an instance of tablet

245
00:14:19,390 --> 00:14:19,960
computer.

246
00:14:20,050 --> 00:14:24,490
So again if I on this step over this if statement is skipped and it's going to actually look at this

247
00:14:24,490 --> 00:14:26,920
condition here it's going to look at this for loop here.

248
00:14:27,070 --> 00:14:32,200
So because this for enhanced for loop is going to be executed for each object that we have inside these

249
00:14:32,200 --> 00:14:33,160
computers.

250
00:14:33,370 --> 00:14:39,910
Now it's actually time for this second object inside this body which is going to be laptop computer.

251
00:14:39,910 --> 00:14:40,610
Right.

252
00:14:40,640 --> 00:14:44,690
So now let's click on that over and it's going to actually look at this condition.

253
00:14:44,700 --> 00:14:50,380
If the computer which is which is actually a laptop computer is an instance of this computer which is

254
00:14:50,560 --> 00:14:56,480
not because laptop is not on this computer so it is a split and evaluates to false here.

255
00:14:56,650 --> 00:15:00,200
If I click on step over you can see that this statement is actually skipped.

256
00:15:00,310 --> 00:15:05,170
And now it's going to say could this if statement here if the computer is an instance of laptop computer

257
00:15:05,170 --> 00:15:06,500
which is actually true.

258
00:15:06,520 --> 00:15:11,570
So it's going to actually execute the lines of code that are inside of the curly braces of this if statement.

259
00:15:11,570 --> 00:15:12,890
This could this step over.

260
00:15:12,910 --> 00:15:19,320
You can see that this line up with it is executed here and the computer is of type Lepp laptop computer.

261
00:15:19,360 --> 00:15:23,180
And if I click on to start over again you can see that now it's going to actually execute this thing

262
00:15:23,180 --> 00:15:27,670
and I've got the laptop computer that said text Cudlitz laptop computer that was stream is going to

263
00:15:27,670 --> 00:15:32,400
call the twisting Meffert of the laptop computer and it's going to output that value to the screen.

264
00:15:32,680 --> 00:15:35,280
So let's click on step over again.

265
00:15:36,030 --> 00:15:41,430
In order to actually execute the other statements you are because we need to do that here and you can

266
00:15:41,430 --> 00:15:43,450
see that they get this expression of too far.

267
00:15:43,450 --> 00:15:46,910
So if this statement is not going to execute it's not going to be executed.

268
00:15:46,920 --> 00:15:49,900
And again we have this condition so again it is going to be false.

269
00:15:49,950 --> 00:15:53,900
If I click on that or you can see that this statement is also skipped.

270
00:15:53,940 --> 00:15:58,910
And now again here it's going to actually highlight the line of what is enhanced for loop.

271
00:15:58,920 --> 00:16:03,480
Now it's time for the word object and say these computers right inside these computers are actually

272
00:16:03,480 --> 00:16:09,370
in the Smart smartphone computer object that is in their index number two of these computers at a.

273
00:16:09,570 --> 00:16:11,810
So here let's click on it.

274
00:16:11,850 --> 00:16:12,770
Step over.

275
00:16:12,810 --> 00:16:17,880
So again this expression here evaluates to false because the smartphone computer is not an object of

276
00:16:17,990 --> 00:16:19,200
this stop computer right.

277
00:16:19,200 --> 00:16:23,740
So they said if they find it's going to be actually skipped Let's get that over so you can see this

278
00:16:23,890 --> 00:16:29,930
is skipped skipped and the lines of code inside the curly braces of this is if statement is not executed.

279
00:16:30,030 --> 00:16:34,530
And we have this condition if the computer is actually on a smartphone computer we can see this computer

280
00:16:34,530 --> 00:16:35,020
here right.

281
00:16:35,020 --> 00:16:36,110
It says iPhone 6.

282
00:16:36,450 --> 00:16:41,580
If the computer which is actually a smartphone computer is an instance of tablet laptop computer.

283
00:16:41,580 --> 00:16:42,600
So it is not.

284
00:16:42,660 --> 00:16:45,230
So this expression evaluates the FARs and it's going on.

285
00:16:45,450 --> 00:16:50,940
Skip this if statement if we actually click on this step over so you can see that is if statement is

286
00:16:50,940 --> 00:16:51,670
actually skipped.

287
00:16:51,870 --> 00:16:53,660
And now we have this statement.

288
00:16:53,730 --> 00:16:55,890
Look at this statement this is very important.

289
00:16:55,890 --> 00:17:01,470
It says if the computer is actually an instance of a smartphone or a computer which is actually completely

290
00:17:01,470 --> 00:17:05,640
true because we have iPhone success and it is off the smartphone computer.

291
00:17:05,640 --> 00:17:11,000
So now it's going to execute the lines of code inside this if statement if I could kind of start over.

292
00:17:11,010 --> 00:17:15,660
Now it's going to try to get this object the current smartphone computer here is going to cast it to

293
00:17:15,870 --> 00:17:17,490
our smartphone computer object.

294
00:17:17,550 --> 00:17:23,010
And now if I could start over again it's going to output the value of the twisting effect of this smartphone

295
00:17:23,010 --> 00:17:28,110
to computer screen TXI the smartphone computer that takes the current smartphone can beat it or twisted

296
00:17:28,110 --> 00:17:33,430
it so you can see that these values for example is iPhone 6 s here right.

297
00:17:33,450 --> 00:17:36,200
So these values are going to be outputted to the screen.

298
00:17:36,210 --> 00:17:42,990
The problem happens when they're actually the tablet computer is going to be actually identified.

299
00:17:42,990 --> 00:17:46,830
So for now let's actually just click on the step over.

300
00:17:46,890 --> 00:17:51,030
So first let me actually to go into the smartphone computer class and let me show you that this smartphone

301
00:17:51,080 --> 00:17:53,750
computer class is an instance of type.

302
00:17:53,840 --> 00:17:58,080
Actually it is inheriting from the computer class.

303
00:17:58,220 --> 00:18:02,900
So this means that the smartphone or computer for instance is actually an instance of the computer class

304
00:18:02,960 --> 00:18:03,710
also.

305
00:18:03,740 --> 00:18:04,390
Right.

306
00:18:04,730 --> 00:18:09,440
So let's go back to the main activity class and now it's about to execute this line of what if the computer

307
00:18:09,470 --> 00:18:14,450
which is actually a smartphone computer we can see that your right is actually an instance of that tablet

308
00:18:14,450 --> 00:18:16,310
computer which is not.

309
00:18:16,480 --> 00:18:22,600
It's going to actually skip this statement because this if statement this expression evaluates to false.

310
00:18:22,610 --> 00:18:27,560
If I can step over we can see that this statement is actually skipped.

311
00:18:27,800 --> 00:18:30,620
And now it's time for the final object inside this area.

312
00:18:30,650 --> 00:18:31,980
This is very important.

313
00:18:32,150 --> 00:18:33,600
Pay your attention here.

314
00:18:33,620 --> 00:18:34,710
This is very important.

315
00:18:34,730 --> 00:18:40,700
Now we have the tablet computer in the index number free which is going to be the final objective for

316
00:18:40,970 --> 00:18:41,720
the Forth object.

317
00:18:41,720 --> 00:18:43,700
And so these Adye tablets computer.

318
00:18:43,850 --> 00:18:46,100
So now let's step over.

319
00:18:46,100 --> 00:18:50,500
So the tablet computer is not an instance of this computer right.

320
00:18:50,540 --> 00:18:53,950
So this statement here is going to be skipped completely.

321
00:18:54,050 --> 00:18:59,130
It's not going to execute this statement because you can see that the computer is of type i-Pad.

322
00:18:59,210 --> 00:18:59,750
OK.

323
00:18:59,930 --> 00:19:05,290
So you can see that this statement is going to be Skipp politically can step over.

324
00:19:05,300 --> 00:19:09,150
So this statement is not executed and now it's going to actually look at this if statement.

325
00:19:09,260 --> 00:19:15,440
If the computer is an instance of laptop computer so it is not because laptop it because actually tablet

326
00:19:15,470 --> 00:19:17,180
is not an instance of laptop computer.

327
00:19:17,180 --> 00:19:20,010
So this statement here is also going to be skipped.

328
00:19:20,060 --> 00:19:21,900
Let's go actually call and click on this.

329
00:19:21,900 --> 00:19:25,340
Step over here and now look at this one here.

330
00:19:25,340 --> 00:19:27,790
This is actually the cause of the problem.

331
00:19:27,790 --> 00:19:29,840
This is the source of the error.

332
00:19:29,840 --> 00:19:37,280
It says if the computer which is actually a tablet computer computer is an instance of type smartphone

333
00:19:37,310 --> 00:19:38,330
computer.

334
00:19:38,330 --> 00:19:42,560
So it is actually this statement here is completely true.

335
00:19:42,560 --> 00:19:44,450
This expression is completely true.

336
00:19:44,450 --> 00:19:45,440
Why.

337
00:19:45,470 --> 00:19:46,320
Let me show you that.

338
00:19:46,430 --> 00:19:52,880
Let's go into the tablet computer class and here you can see that the tablet computer is extending from

339
00:19:52,880 --> 00:19:55,070
the top smartphone computer class.

340
00:19:55,070 --> 00:20:01,490
So this means that there is an ease our relationship between these two classes a tablet computer is

341
00:20:01,550 --> 00:20:03,890
our smartphone computer right.

342
00:20:03,890 --> 00:20:06,260
We specify that explicitly here.

343
00:20:06,350 --> 00:20:07,360
Right.

344
00:20:07,370 --> 00:20:13,640
So this means that an instance of type tablet computer is going to be actually of type tablet computer

345
00:20:13,940 --> 00:20:17,730
and it is going to be also of smartphone computer.

346
00:20:17,780 --> 00:20:20,680
So because there is an inheritance relationship here.

347
00:20:20,840 --> 00:20:27,230
So let's go back to the main activity class and here if I actually click on the step over because this

348
00:20:27,230 --> 00:20:32,720
actually this expression evaluates to true it's going to execute the lines of code here in say the collaborators

349
00:20:32,810 --> 00:20:33,920
of this statement.

350
00:20:34,040 --> 00:20:34,670
Let's click on.

351
00:20:34,690 --> 00:20:39,770
Step where we can see that this expression evaluates to true and it's going to actually execute this

352
00:20:39,770 --> 00:20:40,670
line of what here.

353
00:20:40,690 --> 00:20:42,490
Current smartphone computer.

354
00:20:42,620 --> 00:20:48,070
In other words this statement should not be executed because this is the cause of the error.

355
00:20:48,080 --> 00:20:52,360
If I click on this system over again and now it's going out with this value it's going I think it is

356
00:20:52,360 --> 00:20:58,170
done with here and it's going to output the value of the tablet computer to the text view of the TXI

357
00:20:58,190 --> 00:21:01,570
the smartphone computed of the smartphone computer actually takes a view.

358
00:21:01,760 --> 00:21:08,240
So it's going to call the twistings method of the tablet computer instead of the smart phone computer.

359
00:21:08,240 --> 00:21:12,440
Right because the tablet computer is an instance of smart phone computer.

360
00:21:12,560 --> 00:21:16,850
If I clicked on this start over again and now it's going to actually look at this statement so again

361
00:21:16,880 --> 00:21:23,800
because tablet computer which is actually this one is an instance of top of tablet computer also here.

362
00:21:24,050 --> 00:21:28,850
So it's going to look at these conditions so it this expedition here evaluates to true and it's going

363
00:21:28,850 --> 00:21:30,580
to execute this statement also.

364
00:21:30,710 --> 00:21:33,950
So we can see that this is low enough to here is about to be executed.

365
00:21:34,010 --> 00:21:38,710
And now this one is going out but the value of the tablet computer with it takes the tablet computer.

366
00:21:38,870 --> 00:21:44,300
So let's go because that over and now we can see that all these objects is executed and if you click

367
00:21:44,300 --> 00:21:50,300
on that over you can see that it's actually to reach the final to the ending curly brace of this uncreate

368
00:21:50,300 --> 00:21:50,940
method.

369
00:21:51,230 --> 00:21:54,540
So now you can see that what is the cause of the error.

370
00:21:54,600 --> 00:22:03,670
You actually we actually found out that where the error actually exists the error exists here inside

371
00:22:03,730 --> 00:22:06,620
this statement computer instance of smart phone computer.

372
00:22:06,620 --> 00:22:12,590
So how we can solve this problem in order to solve this problem inside this statement is to create another

373
00:22:12,770 --> 00:22:20,350
statement so if inside parent says here let's actually put a bank here.

374
00:22:20,530 --> 00:22:26,310
These exclamation mark because this exclamation mark is going to reverse the value of a boolean value

375
00:22:26,320 --> 00:22:28,160
if it is actually true it's going to make it false.

376
00:22:28,180 --> 00:22:30,350
And if it is for he's going to make it true.

377
00:22:30,680 --> 00:22:37,750
Let's put a pair of practices here and let's say if bank or exclamation marks we can we can actually

378
00:22:37,750 --> 00:22:47,020
call it bank or exclamation marks right into the apprentice's computer instead of actually tablets computer

379
00:22:49,420 --> 00:22:56,110
then only in that case executes the lines of code here only in that case execute these two lines of

380
00:22:56,110 --> 00:22:56,750
code here.

381
00:22:57,010 --> 00:22:57,260
Right.

382
00:22:57,280 --> 00:22:58,800
So what does this mean.

383
00:22:58,810 --> 00:23:03,510
So this means that the computer is actually off the instance is smarter than a computer.

384
00:23:03,520 --> 00:23:04,550
So it is OK.

385
00:23:04,660 --> 00:23:06,020
It this statement.

386
00:23:06,070 --> 00:23:08,580
And then it's going to go inside the curly braces of this statement.

387
00:23:08,680 --> 00:23:16,270
And it's going to look at this if statement here is going to see that if the computer is not looking

388
00:23:16,290 --> 00:23:22,990
at this bank here is if the computer is not an instance of tablet computer exec could these two lines

389
00:23:22,990 --> 00:23:23,510
of code.

390
00:23:23,650 --> 00:23:27,040
So here we are using that nested if statements here.

391
00:23:27,040 --> 00:23:34,120
Right here we want to make sure that the computer is actually or is not a tablet computer and only in

392
00:23:34,120 --> 00:23:39,330
that case we want to output these values the value of the smartphone computer to the screen.

393
00:23:39,670 --> 00:23:45,390
If I actually don't put this statement here because tablet computer is an instance of type smartphone

394
00:23:45,430 --> 00:23:50,260
computer it's going to actually secure these lines of code and it's going to overwrite the value of

395
00:23:50,260 --> 00:23:52,830
the smartphone computer on the screen.

396
00:23:52,840 --> 00:23:55,900
So now the problem is going to be solved.

397
00:23:55,900 --> 00:23:57,750
Let me actually fall into the break point.

398
00:23:57,750 --> 00:24:02,770
So in order to do the breakpoint you can't just click on it it just they can just click on it and now

399
00:24:02,770 --> 00:24:04,030
the breakpoint is gone.

400
00:24:04,360 --> 00:24:05,770
Let's run our application.

401
00:24:05,770 --> 00:24:10,810
Let me actually click on the start and let me show you the emulator.

402
00:24:10,870 --> 00:24:14,600
So here I just need to actually select one of these devices and then click on OK.

403
00:24:14,710 --> 00:24:20,890
So here you can see that the problem is completely solved and we can see this iPhone 6 as retina screen

404
00:24:21,130 --> 00:24:23,930
virtual keyboard power lab performance.

405
00:24:24,010 --> 00:24:29,230
And we have the tablet computer which is when it's actually specific value use your iPad retina screen

406
00:24:29,380 --> 00:24:32,850
virtual keyboard Sibiu power wrap screen size performance.

407
00:24:32,890 --> 00:24:33,520
Right.

408
00:24:33,900 --> 00:24:39,490
So now the problem is completely solved and we just needed to actually use this statement inside this

409
00:24:39,640 --> 00:24:40,230
statement here.

410
00:24:40,240 --> 00:24:42,440
We have actually a nested IF statement here.

411
00:24:42,490 --> 00:24:47,950
And I was thinking that if the computer that is passed here is not of type tablet computer only in that

412
00:24:47,950 --> 00:24:51,280
case we are going to execute these these two lines of code here.

413
00:24:51,540 --> 00:24:51,980
Right.

414
00:24:53,020 --> 00:25:00,340
So that's it if you want to you can actually create again a breakpoint here in line in line number actually

415
00:25:00,620 --> 00:25:01,560
for 30.

416
00:25:01,570 --> 00:25:07,390
Or it can actually create a regimented in line number 43 and you can control the execution of the program

417
00:25:07,450 --> 00:25:10,820
and see how these lines of code are actually executed.

418
00:25:10,870 --> 00:25:18,040
And I actually completely suggest you to actually do this to practice on your debugging skills because

419
00:25:18,070 --> 00:25:23,150
it is a very important skill in skill in Android If you want to become a professional and the developer

420
00:25:23,170 --> 00:25:28,500
you have to be proficient in the bug in your Android applications.

421
00:25:28,930 --> 00:25:29,540
So that's it.

422
00:25:29,560 --> 00:25:34,300
If you have any questions please post the discussion in the course and then I'll do my best to answer

423
00:25:34,330 --> 00:25:35,270
all of your questions.

424
00:25:35,410 --> 00:25:38,610
Thank you very much for watching and I'll see you in the next tutorial.

