In Integer.java, there is the following piece of code:
/**
* All possible chars for representing a number as a String
*/
final static char[] digits = {
'0' , '1' , '2' , '3' , '4' , '5' ,
'6' , '7' , '8' , '9' , 'a' , 'b' ,
'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
'o' , 'p' , 'q' , 'r' , 's' , 't' ,
'u' , 'v' , 'w' , 'x' , 'y' , 'z'
};
I thought all the digits/characters you would ever need are in the range 0-9 and letters A to F. Letters (A,B,C,D,E and F) would be used only when the numbers are represented in base 16 (hexadecimal).
Why does the Javadoc say "All possible chars" ? Are the letters from G to Z actually used ? I would think that they could be used if the base, we represent the numbers in, is greater than 16.
解决方案
The toString method supports arbitrary bases (like 20) up to MAX_RADIX which is defined as 36