1

将数字转换为不同的基数后:

String thirteenAsBase36 = Long.toString(13, 36);

如何将字符串转换回正常的以 10 为基数的数字?

Long thirteenAsBase10 = ?
4

1 回答 1

7
long parseLong(String s, int radix)
                 throws NumberFormatException

http://download.oracle.com/javase/6/docs/api/java/lang/Long.html

Long thirteenAsBase10;
try
{
    thirteenAsBase10 = Long.parseLong(thirteenAsBase36, 36);
}
catch ( NumberFormatException e )
{
    System.out.println("Oops");
}

您的第一个想法应该始终是:阅读 JavaDocs

于 2011-09-20T23:59:56.650 回答