All language subtitles for 010 Debugging Functions_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,440 --> 00:00:03,620 A lot of the times your function is not going to return the correct value. 2 00:00:04,010 --> 00:00:07,820 So in this lesson, you're going to learn to debug functions by using breakpoints. 3 00:00:09,970 --> 00:00:13,400 Once again, the code you're going to open isn't going to behave the way that you want it to. 4 00:00:14,170 --> 00:00:17,070 So I'll give you a few seconds to pause and read this description. 5 00:00:24,190 --> 00:00:28,660 And now, based on the description you just read, the starter code should place Gryffindor in first 6 00:00:28,660 --> 00:00:30,910 place, but if we actually run it. 7 00:00:34,630 --> 00:00:35,590 They are in fourth. 8 00:00:36,430 --> 00:00:40,390 Something is wrong and using breakpoints, we can visualize the runtime. 9 00:00:56,910 --> 00:01:02,760 OK, well, there's the first mistake, Gryffindor won by 400 points, but the points margin indicates 10 00:01:02,760 --> 00:01:04,330 that they lost by 400. 11 00:01:05,069 --> 00:01:11,760 We need to reverse the operation and this is a very common type of accidental mistake that you can easily 12 00:01:11,760 --> 00:01:13,860 identify when you visualize the runtime. 13 00:01:16,320 --> 00:01:18,390 So let's launch another debugging session. 14 00:01:28,560 --> 00:01:33,690 And the final up, but it's three, but since Gryffindor is ahead by more than 300 points, they should 15 00:01:33,690 --> 00:01:36,580 be in first place to find out what's going on. 16 00:01:36,600 --> 00:01:38,340 We need to step into the function. 17 00:01:39,410 --> 00:01:43,120 When a breakpoint hits the function call, you can step into it. 18 00:01:46,040 --> 00:01:47,810 So restart the debugging session. 19 00:01:52,910 --> 00:01:56,360 Once the breakpoint hits the function, you can step into its. 20 00:02:05,430 --> 00:02:08,910 And after you step into the function, it evaluates the first condition. 21 00:02:10,979 --> 00:02:12,600 For us, the second one. 22 00:02:14,980 --> 00:02:15,430 True. 23 00:02:19,240 --> 00:02:20,230 And they return three. 24 00:02:25,110 --> 00:02:27,720 It stores the return value in the variable ranking. 25 00:02:30,620 --> 00:02:31,790 Which we then printed. 26 00:02:35,950 --> 00:02:39,460 So we need to rearrange the conditions to go from highest to lowest. 27 00:03:19,260 --> 00:03:21,490 All right, now it returns the correct results. 28 00:03:22,110 --> 00:03:26,880 Now we're going to run some test cases and use break points to visualize each runtime will change. 29 00:03:26,880 --> 00:03:30,000 Gryffindor points to eight fifty rather than clode to five hundred. 30 00:03:30,970 --> 00:03:33,250 That should put Gryffindor in first, let's try it out. 31 00:03:43,380 --> 00:03:44,150 OK, good. 32 00:03:46,540 --> 00:03:50,200 Now we'll do 620 and 500 should put them in second. 33 00:04:06,270 --> 00:04:07,510 OK, great. 34 00:04:08,070 --> 00:04:11,070 We'll do 450 and 500, I should put them in third. 35 00:04:29,970 --> 00:04:30,810 Nice. 36 00:04:36,150 --> 00:04:39,330 Then we'll do a hundred and five hundred and I should put them in last. 37 00:04:59,070 --> 00:05:00,270 And indeed, it does. 38 00:05:04,250 --> 00:05:08,740 Now, if you want to explore the hidden world of Java, you can step into built in functions. 39 00:05:09,470 --> 00:05:10,940 I can step into print line. 40 00:05:18,660 --> 00:05:22,260 And this is the code that runs behind the scenes to print your code. 41 00:05:30,820 --> 00:05:32,650 I can step into that random. 42 00:05:50,460 --> 00:05:57,150 Interesting, it returns the next double that the random number generator produces, OK, makes sense. 43 00:06:05,130 --> 00:06:07,200 I can step into math that, Max. 44 00:06:25,420 --> 00:06:27,650 And this syntax is very interesting. 45 00:06:27,670 --> 00:06:31,780 It's called conditional assignment, and I made you use it in the last exercise. 46 00:06:32,620 --> 00:06:36,280 Basically, it checks if value A is greater than or equal to be. 47 00:06:36,700 --> 00:06:40,870 If it's true, Gever returns the value that follows the questionmark. 48 00:06:41,530 --> 00:06:44,800 Otherwise, Javor returns the value that follows the colon. 49 00:06:44,830 --> 00:06:47,660 B. In this case, the condition is false. 50 00:06:47,800 --> 00:06:49,030 So it's going to return B. 51 00:06:57,900 --> 00:07:01,230 All right, one more thing, notice that Java documents every function. 52 00:07:03,280 --> 00:07:09,490 This function takes two parameters and returns the larger of Perram, A and B, very similar to how 53 00:07:09,490 --> 00:07:11,020 we do things pretty cool. 54 00:07:15,290 --> 00:07:17,690 All right, we used breakpoints to debug a function. 55 00:07:18,910 --> 00:07:24,910 You visualized how a function runs by stepping into it, and if you're curious about built in functions, 56 00:07:24,910 --> 00:07:26,530 you can step into those as well. 5186

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.