A live-coding talk where I show off all you need to know about
var in Java. And then some.
In Java 10, 'var' makes it is possible to ad-hoc combine traits into an instance that matches your exact requirements. Alas, it has some downsides.
varand anonymous classes (that you should never use at work)#post
Local-variable type inference with
var makes it easier to work with anonymous classes, e.g. for ad-hoc fields and methods. Don't do it, though!
Java 10's 'var' makes intersection types in Java more approachable. Generics tricks are still needed, but 'var' makes it easy to declare such variables.
Java 10 introduces the var keyword, which lets the compiler infer local variable types. Here's how var works, why it exists, how it impacts readability.