Java Convert integer to hex integer

前端 未结 8 1662
醉话见心
醉话见心 2020-12-01 09:58

I\'m trying to convert a number from an integer into an another integer which, if printed in hex, would look the same as the original integer.

For example:

C

相关标签:
8条回答
  • 2020-12-01 10:59

    The easiest way is to use Integer.toHexString(int)

    0 讨论(0)
  • 2020-12-01 10:59
    String input = "20";
    int output = Integer.parseInt(input, 16); // 32
    
    0 讨论(0)
提交回复
热议问题