Guide To Java 8 Optional Class. Part-I. Bengali-Ep:30 #learnjava #bengali #optional #java8
Hi,
Hope you are all doing great. Let's learn together.
Join Telegram: ? https://t.me/contactajoydebnath
Chapters❤
0:00 Introduction
00:47 Optional Class Theory
02:07 Why Do Developers Need Optional in Java?
05:49 Why Do Developers Need Optional in Java? Coding
18:51 Optional implementation
24:28 empty() method
27:21 of(value) method
30:34 ofNullable(value) method
32:45 isPresent() method
34:19 ifPresent(Consumer consumer) method
Note:
Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, James Gosling and his team changed the name from Oak to Java.
Document Link -
https://docs.google.com/document/d/1qfuQHgmV-e3kY9wTDGdSkPPhMcm78nxK3rExRhexLdI/edit?usp=sharing
STS Link:
https://spring.io/tools
JDK Link:
https://www.oracle.com/java/technologies/downloads/
Video Links:
Core Java Playlist:
https://youtube.com/playlist?list=PL0LQjbMWLlS3AVp2LglGSvfV6ieUSsNMp
Spring Playlist :
https://www.youtube.com/playlist?list=PL0LQjbMWLlS3tXLVZBuLmsMJ9dU6JNtGD
Java Videos Links :
Stream API : Intermediate & Terminal operations. -- https://youtu.be/HVGUhOBGrk8
Stream API: Intermediate & Terminal operations. -- https://youtu.be/nqu-cDQzzAA
Factory Method Design Pattern. -- https://youtu.be/A5JgNaFMiUY
Object Cloning, Shallow Copy and Deep Copy. -- https://youtu.be/YppKcqWoaZA
Excetption, Custom Exception, throw, throws -- https://youtu.be/0cSas4k7CUQ
Excetption, try, catch, finally -- https://youtu.be/8l-fXr_nYe4
Exception, Exception Hierarchy, Call Stack, Propagation. Bengali-Ep:22 -- https://youtu.be/D4cigYGNtu8
Lambda Expression, Functional Interfaces, Anonymous Class. -- https://youtu.be/o88ycNO3R7Q
'super' keyword - https://youtu.be/Jj1E2M6e-O0
'this' keyword - https://youtu.be/x_TJINrbqtk
Static Keyword, Static variable, block, method, nested class - https://youtu.be/tgzUgat88_A
Access Modifier. Private, Public, Default, Protected -- https://youtu.be/Fkkcc6ypCtw
Spring Video Links:
Model-View-Controller(MVC), Spring MVC. -- https://youtu.be/ZPVvmX_yntA
JDBCTemplate, RowMapper,ResultSetExtractor,BeanPropertyRowMapper Spring -- https://youtu.be/NsytsxHTUro
Spring JDBCTemplate, JDBC, Statement and PreparedStatement -- https://youtu.be/jkc3RzTxzXE
What if we remove @Configuration annotation in Spring? -- https://youtu.be/lmQ0sy74QkA
@Configuration, @Bean, @Component, @ComponentScan in Spring. -- https://youtu.be/OXFVdoxX4SE
Like, Comment, Share, and Subscribe.
Thank you again.
Java 8 - Optional Class
Optional is a container object used to contain not-null objects. The Optional object is used to represent null with an absent value. It is introduced in Java 8 and is similar to what Optional is in Guava.
Why Do Developers Need Optional in Java?
Optional is generally used as a return type for methods that might not always have a result to return. For example, a method that looks up a user by ID might not find a match, in which case it would return an empty Optional.
Optional can help to reduce the number of null pointer exceptions in your code.
empty() – To create an empty Optional object, we simply need to use its empty() static method. Optional.empty();
of(T value) – It returns an Optional with the specified present non-null value.
Optional.of(value);
ofNullable(T value) – It returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional.
Optional.ofNullable(value);
isPresent() – It returns true if there is a value present, otherwise false.
opt.isPresent();
ifPresent(Consumer consumer) – If a value is present, invoke the specified consumer with the value, otherwise do nothing.
orElse() – The orElse() method is used to retrieve the value wrapped inside an Optional instance. It takes one parameter, which acts as a default value. The orElse() method returns the wrapped value if it's present, and its argument otherwise.
orElseGet() – The orElseGet() method is similar to orElse(). However, instead of taking a value to return if the Optional value is not present, it takes a supplier functional interface, which is invoked and returns the value of the invocation.
orElseThrow() – The orElseThrow() method follows from orElse() and orElseGet() and adds a new approach for handling an absent value.
filter() – We can run an inline test on our wrapped value with the filter method. It takes a predicate as an argument and returns an Optional object. If the wrapped value passes testing by the predicate, then the Optional is returned.
map() – This operation transforms the value contained in an Optional, if present, and returns a new Optional of the transformed value. If not present, returns an empty Optional.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Guide To Java 8 Optional Class. Part-I. Bengali-Ep:30 #learnjava #bengali #optional #java8», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.