Long myLong = Long.parseLong("1L") // Throws NumberFormatException
我最好的猜测是,这样的额外检查会导致开销,只有 ~1%(或更少)的时间有人调用带有尾随“L”字符的 parseLong
.
但是这个“遗漏”背后可能有不同的原因吗?
最佳答案
在方法java.lang.Long.parseLong(String)中是这样定义的:
The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign ...
关于java - 为什么 Long.parseLong(String s) 不会将尾随 "L"视为有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36739676/