Difference Between int and long


In this post, we will understand the difference between ‘int’ and ‘long’ types.

int

  • It is a datatype.

  • It has 32-bits.

  • In terms of bytes, it takes up 4 bytes.

  • In Java, it is between the range –2,147,483,648 to 2,147,483,647.

  • It is also used as a keyword to declare variable of type integer.

  • In comparison to memory required to store ‘long’ variables, it takes up less memory space.

long

  • It is a data type.

  • It takes 64-bits.

  • In terms of bytes, it takes 8 bytes.

  • In Java, its range is between –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

  • It can also be used as a keyword to declare a variable of type ‘long’.

  • Its memory space requirement is more in comparison to ‘int’.

Updated on: 24-Mar-2021

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements