I know Java doesn\'t allow unsigned types, so I was wondering how it casts an integer to a byte. Say I have an integer a with a value of 255 and I cast the integer to a byte
According to my understanding, you meant
Integer i=new Integer(2); byte b=i; //will not work final int i=2; byte b=i; //fine
At last
Byte b=new Byte(2); int a=b; //fine
or does it just directly copy the last 8 bits of the integer
yes, this is the way this casting works