All language subtitles for 013 Built-in 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
is Icelandic
ig Igbo
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,180 --> 00:00:02,520 Java has so many built in functions. 2 00:00:04,490 --> 00:00:07,910 In this lesson, you're going to look at some examples of built in functions. 3 00:00:10,420 --> 00:00:15,160 First thing I'll need you to do is create a new class by yourself inside the section for a project, 4 00:00:15,160 --> 00:00:20,290 create a new file name built in functions Java, and make sure the built in functions class has the 5 00:00:20,290 --> 00:00:21,220 main method. 6 00:00:27,230 --> 00:00:29,150 So what is a built in function? 7 00:00:29,570 --> 00:00:32,630 A built in function is one that Java already made for you. 8 00:00:33,020 --> 00:00:35,840 Built in functions are general to every application. 9 00:00:37,700 --> 00:00:41,090 For example, every application needs to call the print line function. 10 00:00:41,690 --> 00:00:42,200 Oh, yes. 11 00:00:42,200 --> 00:00:48,170 Every time you go to print line, what you were doing was calling a function named print line and passing 12 00:00:48,170 --> 00:00:49,910 in a string as an argument. 13 00:00:52,520 --> 00:00:58,190 And after you call the function somewhere, somehow you're running an actual function called print line. 14 00:00:58,730 --> 00:01:04,700 That print line function, it receives your string as a parameter, and then somehow print line performs 15 00:01:04,700 --> 00:01:08,060 the magical task of printing your message to the console. 16 00:01:09,110 --> 00:01:11,720 And notice that the print line function is void. 17 00:01:11,750 --> 00:01:14,570 It doesn't need to calculate or return anything. 18 00:01:14,870 --> 00:01:18,920 It only performs the task of printing your message to the console. 19 00:01:19,750 --> 00:01:21,070 How do I know this? 20 00:01:21,160 --> 00:01:25,480 Well, if you hover over the function call, it will tell you that you're calling a void function. 21 00:01:26,350 --> 00:01:30,490 Also, why do we have to write system out before calling the function? 22 00:01:31,180 --> 00:01:36,250 The short answer is the function Print line isn't local to your class, it's in some other class somewhere 23 00:01:36,250 --> 00:01:38,650 else attached to system out. 24 00:01:40,560 --> 00:01:44,090 In any case, inside the built in functions class print. 25 00:01:44,100 --> 00:01:45,180 Hello, Java. 26 00:01:48,280 --> 00:01:49,540 And run your code. 27 00:01:54,510 --> 00:01:59,100 I know it seems silly of me to ask you to print Hello Java, but I hope that you can really appreciate 28 00:01:59,100 --> 00:02:01,080 what's going on behind the scenes. 29 00:02:01,410 --> 00:02:04,830 You're calling the print line function and passing in one argument. 30 00:02:04,860 --> 00:02:05,970 Hello Java. 31 00:02:06,270 --> 00:02:12,420 The print line function existing somewhere it runs and it receives your argument as a parameter. 32 00:02:13,020 --> 00:02:17,700 Then it performs the magical task of printing your message to the console. 33 00:02:21,420 --> 00:02:26,370 Java defines many math functions for you, like log sign or COS. 34 00:02:27,060 --> 00:02:30,240 These functions are part of the math class that Java made for you. 35 00:02:30,690 --> 00:02:36,750 Here's an example of me using the log function to take the natural logarithm of 101.53. 36 00:02:37,350 --> 00:02:43,470 Now, usually these math functions expect a double parameter and return a double value. 37 00:02:45,610 --> 00:02:49,440 Let's say I want to take the log of 119.6. 38 00:02:49,450 --> 00:02:54,490 I would call the log function and pass in 119.6 as an argument. 39 00:02:54,520 --> 00:02:58,990 The log function would run, compute the log and return the value. 40 00:02:59,020 --> 00:03:03,610 Your call now holds the return value which you can store in a variable. 41 00:03:05,680 --> 00:03:09,460 So in Maine, we're going to calculate the sine of 1.2. 42 00:03:10,220 --> 00:03:13,340 And I'm going to store their result in a variable called sign. 43 00:03:23,460 --> 00:03:24,780 Then I'm going to print. 44 00:03:28,080 --> 00:03:30,840 The son of 1.2 is. 45 00:03:35,820 --> 00:03:38,910 The return value that we stored in the variable sign. 46 00:03:39,660 --> 00:03:41,100 I'm going to run my code. 47 00:03:43,290 --> 00:03:46,980 And the sign of 1.2 is indeed 0.93. 48 00:03:47,580 --> 00:03:50,430 But wait, Rianne, how did you know the result would be a double? 49 00:03:50,970 --> 00:03:55,860 Just hover over the call and it tells you the sine function that Java made for you. 50 00:03:55,860 --> 00:04:00,330 It expects a double parameter, and accordingly we pass the A double value. 51 00:04:01,520 --> 00:04:04,580 If you hover back over the call, it also returns a double. 52 00:04:04,580 --> 00:04:10,070 And since the function returns a double, I know to store the return value in a double variable. 53 00:04:12,690 --> 00:04:12,930 Okay. 54 00:04:12,930 --> 00:04:15,960 Now there are math functions that expect more than one parameter. 55 00:04:15,990 --> 00:04:21,810 For example, if I want to calculate two to the power of four, I would need to pass in two arguments 56 00:04:21,810 --> 00:04:24,150 the base and the exponent. 57 00:04:27,140 --> 00:04:30,140 So inside, man, I'm going to calculate two to the power of four. 58 00:04:30,170 --> 00:04:34,100 Double power is equal to math power. 59 00:04:36,580 --> 00:04:40,240 And I'm going to calculate to raise to the power of four. 60 00:04:45,340 --> 00:04:46,960 Then I'm going to print the result. 61 00:04:50,710 --> 00:04:53,620 Two to the power of four is. 62 00:04:55,770 --> 00:04:59,040 The return value from the math power function. 63 00:05:02,510 --> 00:05:03,920 Rerunning this code. 64 00:05:07,190 --> 00:05:11,240 And as I expect to, to the power of four equals 16. 65 00:05:13,760 --> 00:05:19,180 That being said, there are thousands of built in functions when you install the Java development kit. 66 00:05:19,190 --> 00:05:22,660 It comes with thousands of built in functions that you can use. 67 00:05:22,670 --> 00:05:26,060 If you're thinking of memorizing all of them, please stop. 68 00:05:26,450 --> 00:05:28,670 A good developer doesn't memorize code. 69 00:05:28,970 --> 00:05:34,400 A good developer learns to use the internet, read documentation and find resources. 70 00:05:34,880 --> 00:05:37,130 For example, this is how I do things. 71 00:05:37,640 --> 00:05:40,090 Oh, I need to take the square root of a number in Java. 72 00:05:40,100 --> 00:05:41,090 How do I do it? 73 00:05:41,300 --> 00:05:43,700 Is there a built in function that I can call? 74 00:05:44,240 --> 00:05:48,440 Well, I'm assuming it would be a math function, so I would look up math functions. 75 00:05:48,440 --> 00:05:49,970 Java on Google. 76 00:05:52,340 --> 00:05:58,250 The first two links look good, but I always prefer going over to the Oracle documentation. 77 00:06:01,430 --> 00:06:03,620 Then I would do a control f search. 78 00:06:03,620 --> 00:06:04,700 Square root. 79 00:06:06,600 --> 00:06:07,620 And there you go. 80 00:06:07,650 --> 00:06:13,590 It shows me the function that I need, the parameter it expects and the value it returns. 81 00:06:13,620 --> 00:06:17,520 Now I have all the information I need to use this function in my code. 82 00:06:17,940 --> 00:06:21,960 So when you're in doubt about something, go on the Internet and look it up. 83 00:06:22,110 --> 00:06:28,560 I need to emphasize the best Developers know how to use the internet to read documentation and find 84 00:06:28,560 --> 00:06:29,610 resources. 85 00:06:32,350 --> 00:06:37,060 In this lesson, you saw that Java provides thousands of general functions that they think could be 86 00:06:37,060 --> 00:06:38,170 useful to you. 87 00:06:38,470 --> 00:06:41,590 If you're thinking of memorizing all of them, please stop. 88 00:06:41,890 --> 00:06:44,140 A good developer doesn't memorize code. 89 00:06:44,260 --> 00:06:49,060 A good developer learns to use the Internet, read documentation and find resources. 90 00:06:49,390 --> 00:06:52,360 In other words, go on Google and look it up. 8525

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