var keyword in java | var datatype | var datatype in java10 | var to declare variables in java

preview_player
Показать описание
VAR Keyword
In Java, every variable has a data type.
The data type specifies the type of values the variable can store.
Java 10 introduced a new way to declare variables using the var keyword.

var youtube = "okay java";
Java automatically infers the type of a variable using the initial value assigned to a variable declared with var.
Due to this automatic inference of the type of a variable, it is necessary to always assign an initial value to the variable.

We can declare any datatype with the var keyword.
var can be used in a local variable declaration.
var cannot be used without explicit initialization.
var cannot be used in an instance and global variable declaration
var cannot be used as a Generic type.
var cannot be used with Lambda Expression.
var cannot be used for method parameters and return type.
#okayjava
Рекомендации по теме
join shbcf.ru