By default, any integral primitive data type (byte, short, int, long) will be treated as an int type by a java compiler. For bytes and short, if the value assigned to them is in their range, there are no problems and no suffixes are required. If the value assigned to the byte and the short value exceeds their range, explicit tick casting is required.
Example:
byte b = 130;
to overcome this fulfillment.
byte b = (byte)130;
In the case of a long data type, it can take an integer value without any problems. Suppose we denote by
Long l = 2147483647; //which is max value of int
in this case, an L / l type suffix is ββnot required. By default, the value 2147483647 is considered by the java compiler of type int. The casting of the internal type is done by the compiler, and the int is automatically raised to type Long.
Long l = 2147483648; //CE: value is treated as int but out of range
Here we need to put the suffix as L to handle the literal 2147483648 as a long type using the java compiler.
so finally
Long l = 2147483648L;
Utpal Kumar Mar 18 '17 at 12:58 2017-03-18 12:58
source share