java int casting

int to long Java

After knowing primitive data types and Java rules of Data Type Casting (Type Conversion), let us cast int to long. The int takes 4 byte of memory and long takes 8 bytes of memory. Assignment 4 bytes of memory to 8 byte of memory is done implicitly (automatic conversion). byte…

int to short Java

After knowing primitive data types and Java rules of Data Type Casting (Type Conversion), let us cast int to short. The int takes 4 bytes of memory and short takes 2 bytes of memory. Assigning 4 bytes of memory to 2 bytes goes by explicit casting where Programmer should do…

int to byte Java

After knowing primitive data types and Java rules of Data Type Casting (Type Conversion), let us cast int to byte. The byte takes 1 byte of memory and int takes 4 bytes of memory. Assigning 4 bytes of memory to 1 byte of memory requires explicit casting. byte –> short…