Variables in Java are containers that store values of a specific data type. A variable is declared using the format dataType variableName = value, such as int age = 25. Multiple variables can be declared on the same line by separating each variable declaration with a comma. Variable names must begin with a letter, $, or _, can include numbers but not start with them, and cannot use reserved words or white space. By convention, variable names use camel case. Primitive types like int cannot be assigned null values which causes a compilation error.
5. Identifier Declaration
? Identifiers must begin with a letter, a $ symbol, or a _ symbol.
? Identifiers can include numbers but not start with them.
? Since Java 9, a single underscore _ is not allowed as an identifier.
? You cannot use the same name as a Java reserved word.
? You can not use white space in variable.