[英]If you convert a Java Long to another base, how do you get it back from the String it was converted to?
After you convert a number to a different base: 将数字转换为其他基数后:
String thirteenAsBase36 = Long.toString(13, 36);
How do you convert the String back to a normal base 10 number? 如何将字符串转换回以10为基数的普通数字?
Long thirteenAsBase10 = ?
long parseLong(String s, int radix)
throws NumberFormatException
http://download.oracle.com/javase/6/docs/api/java/lang/Long.html 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");
}
Your first thought should always be: read the JavaDocs . 您的第一个想法应该始终是: 阅读JavaDocs 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.