Local-Variable Type Inference (var)

GPTKB entity

Statements (23)
Predicate Object
gptkbp:instanceOf Java language feature
gptkbp:compatibleWith array initializer without explicit type
null initializer
gptkbp:definedIn gptkb:JEP_286
gptkbp:enables type inference for local variables
gptkbp:example var list = new ArrayList<String>();
var stream = Files.lines(path);
gptkbp:hasSyntax var variableName = expression;
https://www.w3.org/2000/01/rdf-schema#label Local-Variable Type Inference (var)
gptkbp:introducedIn gptkb:Java_10
2018
gptkbp:language gptkb:Java
gptkbp:notAllowedFor fields
method parameters
return types
gptkbp:purpose improve code readability
reduce boilerplate
gptkbp:requires initializer
gptkbp:scope local variables
gptkbp:usedIn try-with-resources
for-each loops
gptkbp:bfsParent gptkb:Java_SE_10
gptkbp:bfsLayer 6