✔ Java Keyword Final - Learn Final Variables_Methods_Classes | (Video 133) смотреть онлайн
Java Keyword Final - Learn Final Variables_Methods_Classes
► Free Selenium PDF Book: https://www.rexjones2.com/book-selenium-4-beginners/
► Free Java PDF Book: https://www.rexjones2.com/book-part-1-core-java/
► All Paperback & eBooks: http://tinyurl.com/Rex-Allen-Jones-Books
Social Media Contact
✔ YouTube https://www.youtube.com/c/RexJonesII/videos
✔ Twitter https://twitter.com/RexJonesII
✔ LinkedIn https://www.linkedin.com/in/rexjones34/
✔ GitHub https://github.com/RexJonesII/Free-Videos
✔ Facebook http://facebook.com/JonesRexII
► Download Code and Transcript via GitHub https://github.com/RexJonesII/Free-Videos/tree/master/Video_133%20Final%20Constant
► Transcript
Let’s talk about the keyword final. Final is a way to prevent variables, methods, and classes from changing in our program. Variables are considered constants after applying final. A method cannot be overridden after applying final. When final is applied to classes, the class cannot be inherited by another class.
Starting with variables, we write final before the data type int. Conventionally, the name is written in all capital letters. HOURS = , capital letters identify the variable as a constant meaning it will not change. There are 24 hours in a day. The difference between final and non-final variable is a final variable cannot be reassigned. For example, let’s create a method called:
public void displayDailyHours () {
HOURS = 25;
}
Do you see the error? The error states “HOURS cannot be assigned”.
Look what happens when I remove final. The error goes away. Change the value from 25 to 24 then Add final back and the error comes back. We are only allowed to initialize a final variable one time. Either directly or inside a method.
Final also prevents method overriding. Let’s see what happens when I go to this other class TestFinalTime. Extend the parent class TimeIsATerribleThingToWaste then override the method by clicking CTRL + SPACE and navigating to displayDailyHours. You see there is no problem but if I go back to the parent class then add final to the method after public and save. Now, we see an error in the child class for method.
Hover the error and the error says Cannot override the final method.
Declaring a class as final, implicitly declares all of its methods as final. A final class prevent inheritance. If I add final between public and class, then we see an error that’s different from the previous error and it says Cannot subclass the final class.
To recap, let’s go over this again. Final Variables Cannot Be Changed because they are considered Constant Variables. Final Methods Cannot Be Overridden Because so they Prevent Method Overriding, and final Classes Cannot Be SubClassed so they Prevent Inheritance.
Thanks for watching. If you like the video then Connect with me on LinkedIn, follow me on Twitter, and subscribe to my YouTube channel. See you next time.
#JavaFinalKeyword #JavaFinalVariable #JavaFinalMethod #JavaFinalClass
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «✔ Java Keyword Final - Learn Final Variables_Methods_Classes | (Video 133)» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.