Unexpected NumberFormatException while parsing a hex string to an int value

后端 未结 5 1437
小鲜肉
小鲜肉 2021-01-26 02:22

I want to parse an String containing 8 hex-digits (4bytes) but i got an NumberFormatException. What is wrong here?

assertThat(Integer.parseInt(\"FFFF4C6A\",16),i         


        
5条回答
  •  一个人的身影
    2021-01-26 03:05

    If you just want to represent that hex string as an integer (since it is 32 bits), you need to use BigInteger:

    new BigInteger("FFFF4C6A", 16).intValue()
    

提交回复
热议问题