I know that if we are performing arithmetic operations on byte value,then implicitly it is promoted to an int and the result will be an int,and hence we need to explicitly convert it into byte in order to store the result in a byte variable. But I wanted to ask-
- Does the conversion from byte to an int happens at the time when it is declared or does it happens when we use it in arithmetic operation? Because the java decompiler I am using converts it from byte to an int at the time of declaration.So,is it the decompiler problem or is it really so.
- And if it really happens at the time of declaration,then why storing a value beyond the range of byte shows an error?
Eg- The code is-
public class Hello
{
public static void main(String[] args)
{
byte a=90;
}
}