byte to char to int..

and what is the result?!

This is the sample code I have..
class CastTest {
    public static void main(String... _) {
        final byte myByte = -1;
        final char myChar = (char) myByte;
        final int myInt = (int) myChar;
Can you guess what the output will be?
myByte is represented as:
Then when widining to char, we fill the additional bits with 1, not 0, 1! A good explanation can be found here! Quoting..
When converting between the int, byte, short, char and boolean types the JVM needs to either add or truncate bits.
If the target type is represented by more bits than the type from which it is converted, then the JVM simply fills the additional slots with the value of the highest bit of the given value.
So because the highest bit we have is 1, just keep filling with 1, where myChar ends up as follows..
Now we will further widen our value, from char (unsigned 16-bit) to int (signed 32-bit) but this time we will break the rule mentioned above, quoting again..
An exception from this rule is widening a char type which is, as we said before, unsigned. A conversion from a char is always applied by filling the additional bits with 0 because we said there is no sign and thus no need for an inverted notation.
So we end up with..
which equals... 65535!

Another mystery solved!