Initialize unsigned byte array using hex number

后端 未结 1 536
猫巷女王i
猫巷女王i 2021-02-08 16:09

I know that unsigned byte is missing in Java Then how can I initialize the byte array using integer from 0 to 255 (in hex)?

1条回答
  •  误落风尘
    2021-02-08 16:35

    You have to store 0x80 in byte like this :

    final byte assoc_resp_msg_int[] = new byte[] {
            (byte)0xe3, 0x00, //APDU CHOICE Type(AareApdu)
            0x00, 0x2c, //CHOICE.length = 44
            0x00, 0x00, //result=accept
            0x50, 0x79, //data-proto-id = 20601
            0x00, 0x26, 
            (byte)0x80,
    ...
    }
    System.out.println(assoc_resp_msg_int[10]&0xFF);
    //128
    

    0 讨论(0)
提交回复
热议问题