Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
A lot of the times your function is not going to return the correct value.
So in this lesson, you're going to learn to debug functions by using breakpoints.
Once again, the code you're going to open isn't going to behave the way that you want it to.
So I'll give you a few seconds to pause and read this description.
And now, based on the description you just read, the starter code should place Gryffindor in first
place, but if we actually run it.
They are in fourth.
Something is wrong and using breakpoints, we can visualize the runtime.
OK, well, there's the first mistake, Gryffindor won by 400 points, but the points margin indicates
that they lost by 400.
We need to reverse the operation and this is a very common type of accidental mistake that you can easily
identify when you visualize the runtime.
So let's launch another debugging session.
And the final up, but it's three, but since Gryffindor is ahead by more than 300 points, they should
be in first place to find out what's going on.
We need to step into the function.
When a breakpoint hits the function call, you can step into it.
So restart the debugging session.
Once the breakpoint hits the function, you can step into its.
And after you step into the function, it evaluates the first condition.
For us, the second one.
True.
And they return three.
It stores the return value in the variable ranking.
Which we then printed.
So we need to rearrange the conditions to go from highest to lowest.
All right, now it returns the correct results.
Now we're going to run some test cases and use break points to visualize each runtime will change.
Gryffindor points to eight fifty rather than clode to five hundred.
That should put Gryffindor in first, let's try it out.
OK, good.
Now we'll do 620 and 500 should put them in second.
OK, great.
We'll do 450 and 500, I should put them in third.
Nice.
Then we'll do a hundred and five hundred and I should put them in last.
And indeed, it does.
Now, if you want to explore the hidden world of Java, you can step into built in functions.
I can step into print line.
And this is the code that runs behind the scenes to print your code.
I can step into that random.
Interesting, it returns the next double that the random number generator produces, OK, makes sense.
I can step into math that, Max.
And this syntax is very interesting.
It's called conditional assignment, and I made you use it in the last exercise.
Basically, it checks if value A is greater than or equal to be.
If it's true, Gever returns the value that follows the questionmark.
Otherwise, Javor returns the value that follows the colon.
B. In this case, the condition is false.
So it's going to return B.
All right, one more thing, notice that Java documents every function.
This function takes two parameters and returns the larger of Perram, A and B, very similar to how
we do things pretty cool.
All right, we used breakpoints to debug a function.
You visualized how a function runs by stepping into it, and if you're curious about built in functions,
you can step into those as well.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.