There is no error when I try to autobox i2 to Byte,but when I do vise-versa(b1 to Integer),then an error occurs.
final byte b1 = 1;
Integer i1 = b1; //error
final int i2 = 1;
Byte b2 = i2;// no error
byte b3 = 1;
int i3 = b3; // no error
Can I suggest that you read JLS Sec 5.2, that I linked in my answer to your previous similar question.
Taking your cases in reverse order:
Assigning a
byteto anintis simply a widening conversion.This is exactly the same as your previous question: you can assign a constant-valued
intto aByte, provided the value of thatintfits into abyte.You're trying to do a widening primitive conversion, followed by a boxing conversion. That's not one of the cases listed here, so it's an error.
You can fix this with an explicit widening cast: