Java Convert integer to hex integer

前端 未结 8 1696
醉话见心
醉话见心 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:41

    Simply do this:

    public static int specialNum(num){
    
        return Integer.parseInt( Integer.toString(num) ,16)
    }
    

    It should convert any special decimal integer to its hexadecimal counterpart.

提交回复
热议问题