~/talk

Do You Use the Optional Class as It Should Be

Talkat Devnexus 2021 · 2021-02-17..02-18· [java]
slides:none on file

25+ practical recipes for Java Optional show exactly what to do and what to stop doing: initialize with Optional.empty instead of returning null, never blindly call get(), prefer orElseGet over orElse for computed defaults, use orElseThrow (since Java 10) for custom exceptions, and prefer ifPresent/ifPresentOrElse, map vs flatMap, OptionalInt/Long/Double for primitives, and Optional::stream to hook into Stream pipelines. Also covers anti‑patterns: no Optional fields, constructor/setter/argument usage, or Optional for collections.

AI-written summary · about

  1. 0:00Introduction to Optional
  2. 3:11Surviving null pointer exceptions
  3. 7:44Handling empty Optional values
  4. 13:59Consuming Optional effectively
  5. 23:14Designing APIs with Optional
  6. 33:37Advanced Optional usage
  7. 43:07Summary and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.