TheBook TheBook - 1 year ago 152
Java Question

Initialize byte[] in java

I have seen the following byte initialization in a tutorial. I just want to ask whether the array includes 17 bytes after initialization and if yes why did he not use 11 hexadecimal to get a decimal value of 17?

byte[] decoded = new byte[0x0f + 2];

Answer Source

Yes, the array will have a length of 17 bytes.

As to why the programmer did this, it's impossible to know from what you've posted. My guess is that 0x0f has a special meaning within the application and the + 2 is two bytes of additional buffer space and 2 also has some special meaning.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download