I have to use quite a big number - 600851475143; as we all know, I have to use long data type but when I try to initialize like: long number = 600851475143
I get an error:
The literal 600851475143 of type int is out of range.
It seems that I don't know how to use long data type correctly.
HASHTABLE is a structure of Key value pairs.. Here what the values passed by the SET is treated as Keys of HASHTABLE Internally. keys are unique cannot be duplicated.
long: The long data type is a 64-bit two's complement integer. The signed long has a minimum value of -263 and a maximum value of 263-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1.
long number = 600851475143L
Use "L" to make it as long type
Use "L" to make it as long type. By default all integer type variable(byte,int,long) is "int"
long num=600851475143L;
or
long num=600851475143l; // small 'L'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With