Variables in Java
Variables in Java ?
Variables
are the basic requirements in
any program be it Java,Python or JavaScript .It is the
basic unit of storage. It acts as a container and is used to hold data values.
The values held by the variable can be changed during the execution of the
program. Every variable is assigned a data type. Variable, in simpler terms,
is a name given
to a memory location.
Variables
are the basic requirements in
any program be it Java,Python or JavaScript .It is the
basic unit of storage. It acts as a container and is used to hold data values.
The values held by the variable can be changed during the execution of the
program. Every variable is assigned a data type. Variable, in simpler terms,
is a name given
to a memory location.
- Variable Declaration and Initialization
A variable is declared by specifying the following parameters:
·
Datatype: The type of data
that is stored in the variable.
·
Variable name: The
unique name given to the variable.
·
Value: The initial value
stored in the variable.
Variables naming convention in java
Variables naming convention in java
- Variables naming cannot contain white spaces, for example: int num ber = 100; is invalid because the variable name has space in it.
- Variable name can begin with special characters such as $ and _
- As per the java coding standards the variable name should begin with a lower case letter,
- for example int number ; For lengthy variables names that has more than one words do it like this: int smallNumber; int bigNumber; (start the second word with capital letter).
- Variable names are case sensitive in Java.
Comments