您好,在此先感谢,Scanner.hasNextLong错误
我在与java.util.Scanner中这里的一个问题是我的代码:
public static void ScanInput(String Choice) {
if(scanner.hasNextLong()){
long input = scanner.nextLong();
long length = String.valueOf(input).length();
if(length <= 10){
if(Choice == Choice1){
Converter.Decimal(input);
} else if(Choice == Choice2) {
Converter.Binary(input);
}
} else {
System.out.println(error);
scanner.close();
ScanInput(DecimalToBinary.choice);
}
} else {
System.out.println(error);
scanner.close();
ScanInput(DecimalToBinary.choice);
}
scanner.close();
}
利用这个其实并不重要。问题是,当我输入一个大于10位的值时,它会崩溃。所以,似乎我使用了一个整数左右?
(由于int的最大大小)。在
但我用很长....
我调试教练点,如果(scanner.hasNextLong()){
而这也是在那里的东西去拉屎的地方。 .. 请帮忙!
*大于10位*精确度有多大? – Tunaki