Variables

Variables are like containers which holds the data values. A variable specifies the name of the memory location.

How to declare variables


Naming convention of variables

  • Variable names can have only letters (both uppercase and lowercase letters), digits and underscore(_).
  • Variables naming cannot contain white spaces like first name which is a invalid variable name.
  • First letter of a variable should be either a letter or an underscore(_).
  • It is always advisable to give some meaningful names to variables.

Example

Declaring integer variable and assigning value


Declaring decimal variable and assigning value


Declaring String variable and assigning value


Declaring Boolean variable and assigning value