inScanner类可以用什么方法来接受负数? [英] What method inScanner class can be used to accept negative numbers?

查看:148
本文介绍了inScanner类可以用什么方法来接受负数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

扫描仪类可以采用负数吗?

Can scanner class take negative numbers?

推荐答案

显然,这些是方法 nextBigInteger nextDouble nextFloat nextInt 等,具体取决于类型你要解析:

http:// docs .oracle.com / javase / 7 / docs / api / java / util / Scanner.html [ ^ ]。



-SA
Apparently, these are the methods nextBigInteger, nextDouble, nextFloat, nextInt, etc., depending on the type you want to parse:
http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html[^].

—SA


您可以通过上述所有方法将负数作为输入,但我建议不要使用扫描仪,因为它很慢。始终使用 BufferedReader 来获取输入&输出 PrintWriter
You can take negative number as input by all methods above mentioned but I would recommended not to use Scanner because it is damn slow. Always use BufferedReader to take input & PrintWriter for output.


这篇关于inScanner类可以用什么方法来接受负数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆