Integer datatypes are those whose variables can store negative and positive values.
Types of Integer Datatype
There are 2 integer types that we can use to store values.
- Integer (4 bytes) → Range(-2147483647 to +2147483647)
- Long (8 bytes) → Range (-263 to +263-1)
Syntax of Integer Datatype
Integer intValue = 343;
- If the literal goes out of the integer range then append l or L at the end of the literal because by-default a number is treated as an integer.
Eg.
Long largeValue = 3434343434L;
- If the value is not in the range of type defined then the compiles time error is generated.