~/talk

Pattern Matching in Java

Talkat Great International Developer Summit 2024 · 2024-04-23..04-26· [java]
slides:none on file

Shows how Java replaces long conditional chains — recalled 169 if-else — with actual value-returning switch expression syntax using arrows and yield, and demonstrates object pattern matching via instanceof with inline variable binding. Uses records plus sealed interfaces to avoid defaults, illustrates guarded patterns (e.g., sell quantity >= 5,000 triggers audit), dominance checks by the compiler, destructuring of records, and notes Java 22 adds underscore wildcards; examples compile and run, with the compiler inserting a runtime-default if enums expand without recompilation.

AI-written summary · about

  1. 0:00Introduction to pattern matching
  2. 5:43Switch statements vs expressions
  3. 10:02Switch expressions explained
  4. 16:08Switch completeness and defaults
  5. 22:34Pattern matching with instance of
  6. 35:51Data-oriented programming with pattern matching
  7. 41:28Sealed classes and records
  8. 53:28Destructuring in Java
  9. 59:24Java 22 features and underscore
~/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.