concept long in category java

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide.
long
It’s similar to what is shown in figure 4.10, where someone is forcefully trying to squeeze a bigger value (long) into a smaller container (int).
Figure 4.10 Assigning a bigger value (long) to a variable (int) that is only capable of storing smaller value range
![]()
Compare the previous assignment example (assigning a long to an int) with the following example that assigns a smaller value (int) to a variable (long) that is capable of storing bigger value ranges:
int intVal = 1009; long longVal = intVal; #AAn int can easily fit into a long because there’s enough room for it (as shown in figure 4.11).
Figure 4.11 Assigning a smaller value (int) to a variable (long) that is capable of storing a larger value range
![]()
Exam Tip You can’t use the assignment operators to assign a boolean value to variables of type char, byte, int, short, long, float, or double, or vice versa.

This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.
In the final line of the preceding code, a literal value 10 is assigned to the variable long2 of type long, which is acceptable. An attempt to assign the value of the variable long2 to int1 fails because it would need an explicit cast.
long
It’s similar to what’s shown in figure 2.15, where someone is forcefully trying to squeeze a bigger value (long) into a smaller container (int).
Figure 2.15. Assigning a bigger value (long) to a variable (int) that’s only capable of storing a smaller value range
![]()