~/talk

Local Variable Type Infrerence: Friend or Foe.

Talkat Devoxx Ukraine 2020 · 2020-11-05..11-07· [java]
slides:none on file

Local variable type inference (var) in Java SE 10 infers concrete types from initializers but has concrete gotchas: must initialize var and null and array initializers rejected (e.g. new int[] works but {1,2,3} doesn't), numeric literals infer int (breaking byte/short/long-sized protocols), lambdas and polyexpressions need explicit target types, and combining diamond + var can infer Object for generics (PriorityQueue<Integer> becomes PriorityQueue<Object>). JDK11 adds var lambda params for annotations; use var where the RHS clearly shows the type and avoid it when inference changes semantics (overloads, masking, serialization).

AI-written summary · about

  1. 0:00Introduction
  2. 2:20Java Variables
  3. 4:00Local Variable Type Infrerence
  4. 6:07Simple Uses
  5. 12:29Final NonFinal
  6. 14:31Action of the Distance
  7. 17:09Edge Cases
  8. 20:00Null
  9. 25:49Beware of multiple type inference
  10. 28:13Polymorphism
  11. 30:36Lambda Expression
  12. 32:39Type Infrerence
  13. 33:47Generics
  14. 37:17Inner Classes
  15. 38:36Reserved Types
  16. 40:19var
  17. 42:50var vs int
  18. 44:52Summary
~/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.