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
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
Java has so many built in functions.
In this lesson, you're going to look at some examples of built in functions.
First thing I'll need you to do is create a new class by yourself inside the section for a project,
create a new file name built in functions Java, and make sure the built in functions class has the
main method.
So what is a built in function?
A built in function is one that Java already made for you.
Built in functions are general to every application.
For example, every application needs to call the print line function.
Oh, yes.
Every time you go to print line, what you were doing was calling a function named print line and passing
in a string as an argument.
And after you call the function somewhere, somehow you're running an actual function called print line.
That print line function, it receives your string as a parameter, and then somehow print line performs
the magical task of printing your message to the console.
And notice that the print line function is void.
It doesn't need to calculate or return anything.
It only performs the task of printing your message to the console.
How do I know this?
Well, if you hover over the function call, it will tell you that you're calling a void function.
Also, why do we have to write system out before calling the function?
The short answer is the function Print line isn't local to your class, it's in some other class somewhere
else attached to system out.
In any case, inside the built in functions class print.
Hello, Java.
And run your code.
I know it seems silly of me to ask you to print Hello Java, but I hope that you can really appreciate
what's going on behind the scenes.
You're calling the print line function and passing in one argument.
Hello Java.
The print line function existing somewhere it runs and it receives your argument as a parameter.
Then it performs the magical task of printing your message to the console.
Java defines many math functions for you, like log sign or COS.
These functions are part of the math class that Java made for you.
Here's an example of me using the log function to take the natural logarithm of 101.53.
Now, usually these math functions expect a double parameter and return a double value.
Let's say I want to take the log of 119.6.
I would call the log function and pass in 119.6 as an argument.
The log function would run, compute the log and return the value.
Your call now holds the return value which you can store in a variable.
So in Maine, we're going to calculate the sine of 1.2.
And I'm going to store their result in a variable called sign.
Then I'm going to print.
The son of 1.2 is.
The return value that we stored in the variable sign.
I'm going to run my code.
And the sign of 1.2 is indeed 0.93.
But wait, Rianne, how did you know the result would be a double?
Just hover over the call and it tells you the sine function that Java made for you.
It expects a double parameter, and accordingly we pass the A double value.
If you hover back over the call, it also returns a double.
And since the function returns a double, I know to store the return value in a double variable.
Okay.
Now there are math functions that expect more than one parameter.
For example, if I want to calculate two to the power of four, I would need to pass in two arguments
the base and the exponent.
So inside, man, I'm going to calculate two to the power of four.
Double power is equal to math power.
And I'm going to calculate to raise to the power of four.
Then I'm going to print the result.
Two to the power of four is.
The return value from the math power function.
Rerunning this code.
And as I expect to, to the power of four equals 16.
That being said, there are thousands of built in functions when you install the Java development kit.
It comes with thousands of built in functions that you can use.
If you're thinking of memorizing all of them, please stop.
A good developer doesn't memorize code.
A good developer learns to use the internet, read documentation and find resources.
For example, this is how I do things.
Oh, I need to take the square root of a number in Java.
How do I do it?
Is there a built in function that I can call?
Well, I'm assuming it would be a math function, so I would look up math functions.
Java on Google.
The first two links look good, but I always prefer going over to the Oracle documentation.
Then I would do a control f search.
Square root.
And there you go.
It shows me the function that I need, the parameter it expects and the value it returns.
Now I have all the information I need to use this function in my code.
So when you're in doubt about something, go on the Internet and look it up.
I need to emphasize the best Developers know how to use the internet to read documentation and find
resources.
In this lesson, you saw that Java provides thousands of general functions that they think could be
useful to you.
If you're thinking of memorizing all of them, please stop.
A good developer doesn't memorize code.
A good developer learns to use the Internet, read documentation and find resources.
In other words, go on Google and look it up.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.