Integer literals can be assigned to byte or short variables as long as the value of the literal is within the range of byte/short.
But when long literal is assigned to int variable, compilation error is reported even when the value of long literal is within the range of int.
What is the logic explaining this?
Example,
The below line gets compiled successfully
byte byteVar = 100; //works, here 100 is integer literal.
but
int intVar = 100L; // fails, here 100L is long literal
results in compile time error.
Can someone please explain the underlying logic that drives this.