0

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];
buffer.readBytes(decoded)
Ma3x
6,6472 gold badges22 silver badges27 bronze badges
asked Sep 26, 2016 at 18:49
1
  • 2
    Not enough context to answer second question. Idle speculation - the author is trying to communicate that a few extra bytes are included -- e.g., for line separators , null bytes, or failsafe padding. Commented Sep 26, 2016 at 18:52

1 Answer 1

3

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.

answered Sep 26, 2016 at 18:51
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.