I have a byte array I want to assign as follows:
- First byte specifies the length of the string:
(byte)string.length() - 2nd - Last bytes contain string data from
string.getBytes()
Other than using a for loop, is there a quick way to initialize a byte array using bytes from two different variables?
byteis an unsigned type in Java.int, they'll be sign-extended. So you have to mask the sign-extended value to get the range 0..255:b & 0xFF