When you perform the ParseInt
operation with the radix, the 11 base 16 is parsed as 17, which is a simple value. It is then printed as radix 10.
You want:
System.out.println(Integer.toString(11, 16));
This takes the decimal value 11(not having a base at the moment, like having "eleven" watermelons(one more than the number of fingers a person has)) and prints it with radix 16, resulting in B
.
When we take an int
value it's stored as base 2 within the computer's physical memory (in nearly all cases) but this is irrelevant since the parse and tostring conversions work with an arbitrary radix (10 by default).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…