Decoding Hex: What does this line do (len & 0x01) != 0

后端 未结 3 1642
北海茫月
北海茫月 2021-01-25 21:33

I was going through a piece of code in the Apache commons library and was wondering what these conditions do exactly.

public static byte[] decodeHex(final char[         


        
3条回答
  •  爱一瞬间的悲伤
    2021-01-25 22:02

    This line checks if len is an odd number or not. If len isn't odd, len & 1 will be equal to 0. (1 and 0x01 are the same value, 0x01 is just the hexadecimal notation)

提交回复
热议问题