❮ Previous Next ❯

Java Integer Data types

These datatype represent integer numbers i.e. numbers without any fractional part or decimal points. for example: 250,-125,0,1045 etc.

Java support four types of 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

Sl.no Datatypes Memory size Range
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
4 long 8byte -9,223,372,036,854,775,854
775,808 to +9,223,372,036,8954


byte a;
short b;
int e;
long s;

When 1st statement is executed 1 byte of memory will be allocated named as a.

Similarly when 2nd statement is executed 2 byte 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 allocate 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.

❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved