有人能告诉我为什么当我打字inputDouble
(作为当然双),有条件不让我通过。我也尝试过这种浮动类型,结果是一样的。扫描仪类 - hasNextDouble()
编辑:条件传递时,我输入整数。
public static void main(String[] args) {
Scanner inputDouble = new Scanner(System.in);
System.out.println("Double");
if(inputDouble.hasNextDouble()){
System.out.println("Passed");
}
inputDouble.close();
}
感谢您的帮助。
解决:CODE是好的我打字输入法使用DOT INSTEAD逗号
尝试我测试的代码,并通过了条件。 – Farahmand
你能展示你传递的价值吗? –
也许你的语言环境需要不同的格式,然后你提供了两倍的格式。试用'1.2'或'1,2'。 – Pshemo