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)
-
2Not 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.Andy Thomas– Andy Thomas2016年09月26日 18:52:57 +00:00Commented Sep 26, 2016 at 18:52
1 Answer 1
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
Ted Hopp
235k49 gold badges413 silver badges533 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-java