In java, it is fine to have:
byte b = (int) 2;
where java automatically convert int to byte. On the other hand, if we do:
int a = 2;
byte b = a;
this will give an error saying that the required type is byte but int is provided.
May I ask how to understand the reason why automatic conversion works when literal number of type int is assigning to a variable of type byte while it doesn't work when the literal number is replaced by a variable of type int?
Thanks in advance!