Is there a difference between declaring var x
and int x
?
//Java 8
int x = 10;
//Java 10
var x = 10;
Is there a difference between declaring var x
and int x
?
//Java 8
int x = 10;
//Java 10
var x = 10;
There is no run-time difference. var
is compile-time syntactical sugar. If you replace var
with the inferred type (int
) you get identical results.