Var with Style: Local Variable Type Inference in Java
summary
Java 10’s var infers the local type from the right-hand side and must have an initializer, so declarations like var x; or var x = null or var x = (untyped) lambda are disallowed. Reassignment is allowed but the inferred type stays fixed; use final var for immutability. Watch for pitfalls with generics and avoid var+diamond because type arguments may be lost; practical demos use NetBeans 9 on a JSON‑P example and show cleanup of imports. See style guide on OpenJDK.
AI-written summary · about
chapters (6)
- 0:00Introduction to var
- 8:40Focusing on code readability
- 11:44Style guide and principles
- 17:38Practical code examples
- 28:18IDE demonstration
- 32:41Summary and Q&A
related talks
46mLocal Variable Type Infrerence: Friend or Foe.
57mLocal variable type inference: Friend or foe?
53mFun with var in Java 11
55mLocal Variable Type Inference: Friend or Foe?
01h 00mJava Language Futures - All Aboard Project Amber
48mType Variance in Java and Kotlin
16mThe past, present and future of the Java type system
29mJava Method-Local Inner Classes are Unsound
