- Variables are containers to hold values.
- Every variable has name and type, or we can say that a variable is a combination of identifier and datatype.
- Every variable is an identifier, but every identifier is not a variable.
Properties to define a valid variable
- The should not contain any space
- They should not start with digit.
- Only dollar symbol ($), and underscore symbol( _ ) is allowed to use in the java variable.
- Java is a case-sensitive language hence a variable named “a” and “A” have different meanings.
In java there are different types of variables mentioned as follows-
- int - 4 byte
- Float - 4 byte
- Char - 2 byte
- Boolean - 1 bit
- String (string is not a data type in java it is a class).