Annotation Type var
public @interface var
Use
var
as the type of any local variable declaration (even in a for
statement), and the type will be inferred from the initializing expression
(any further assignments to the variable are not involved in this type inference).
For example: var x = 10.0;
will infer double
, and var y = new ArrayList<String>();
will infer ArrayList<String>
.
Note that this is an annotation type because var x = 10;
will be desugared to @var int x = 10;
Complete documentation is found at the project lombok features page for @var.