~/talk

Type inference: Friend or foe?

Talkat JPoint 2021 · 2021-04-13..04-17· [java]
slides:none on file

Java adds local type inference with Java 10’s var and Java 11 relaxes annotations on lambda params; inference runs at compile time so bytecode for var and explicit types is identical (no runtime overhead). Practical pitfalls: comparing().reversed() loses context -> Object so a lambda parameter type can fail to infer, using var with the diamond operator can widen List<T> to List<Object>, and var is illegal for fields and as a lambda target. Use var for local, obvious types, nested-generic clutter, and temporary debug variables; prefer explicit types when in doubt.

AI-written summary · about

  1. 0:00Introduction and welcome
  2. 4:05What is type inference
  3. 7:14Type inference in Java over the years
  4. 13:39Type inference limitations in Java 8
  5. 22:12How type inference works with context
  6. 28:07Introducing the var keyword in Java 10
  7. 35:15Caveats and pitfalls of type inference
  8. 47:57Benefits of using type inference
  9. 59:11Targeted intersection types with var
  10. 1:03:12Type inference for lambda parameters in Java 11
  11. 1:06:52Recommendations and best practices
  12. 1:09:41Type inference: friend or foe?
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.