var (type inference)
Infers the type automatically (Java 10+).
Syntax
var name = value;
Description
Type is understood from the value; shortens the syntax for local variables.
Example
Loading editor…
Expected output
42
When to use?
Short local variable definition.