To convert from byte
to short
, would I be right to assume there's some kind of method being called in the background with the signature:
short byte2Short(byte b);
But what about the situation where a byte
has to be converted to a long
? I.e. in the conversion diagram they are not connected directly by a arrow.
Is there a specific method that converts a byte
into a long
such as:
long byte2Long(byte b);
Or instead does it call a chain of methods that converts the byte as follows:
short byte2Short(byte b);
int short2Int(short s);
long int2Long(int i);
So essentially my question is, if converting from a byte to a long, is the conversion direct like:
byte -> long
Or is it indirect like:
byte -> short -> int -> long
The conversion happens directly, i.e., byte -> long
.
If the types have the same signedness (both signed or both unsigned), the operand whose type has the lesser conversion rank1 is implicitly converted2 to the other type.