Initialize unsigned byte array using hex number

后端 未结 1 1053
挽巷
挽巷 2021-02-08 15:49

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:38

    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)
提交回复
热议问题