What does the second line in the following code represent?
long longNumber = Integer.MAX_VALUE;
int intNumber = (int) longNumber;
I've created a longNumber and assigned it MAX_VALUE. What does the second line mean? Thanks in advance.
What does the second line in the following code represent?
long longNumber = Integer.MAX_VALUE;
int intNumber = (int) longNumber;
I've created a longNumber and assigned it MAX_VALUE. What does the second line mean? Thanks in advance.
Writing "(Generic Type) VariableName" mean that you are changing the type of "VariableName" this syntax is called "CASTING"
In this case you are converting a Long variable to an Int variable.
Casting is not always a secure method becouse if the LONG number is higher than Integer.maxvalue the number will NOT be converted in the correct way (becouse LONG type has more bits than normal INT)