Java Integer Data types
These data types represent integer numbers i.e. numbers without any fractional part or decimal points. for example: 250,-125,0,1045 etc.
Java supports four types of an integer such as byte, short, int and long. Java does not support the concept of unsigned types, therefore all Java values are signed that means either positive or negative.
The following table shows the memory size and range of integer type
|1||byte||1byte||-128 to +127|
|2||short||2 byte||-32768 to +32767|
|3||int||4byte||-2,147,483,648 to +2,147,483,647|
775,808 to +9,223,372,036,8954
When 1st statement is executed 1 byte of memory will be allocated named as a.
Similarly when 2nd statement is executed 2 bytes of memory will be allocated named as s.
Suppose a statement
long p = 135L;
Here 135 is stored into p which is declared as long type. Note that L at the end of the statement. If L is not there, JVM allocates 2 bytes of memory to P as against the usual 8 bytes memory that should be allocated to a long type. The reason for this is that 2bytes are sufficient to store the value 135. But L at the end of the values as shown in the preceding example.
This JVM will consider it as long values and will allocate 8byte of memory to it.
Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Projects
SILAN Technology Call to: 9439202111 | 9658317757 | 0674-2361252