Redian新闻
>
怎么从键盘输入整数或float?
avatar
怎么从键盘输入整数或float?# Java - 爪哇娇娃
w*u
1
我发现有个网友写过,但不能用.本人刚刚接触java,谢谢大家帮忙!!!!
float x = 0.0;
String line = null;
try {
line = System.in.readLine();
}catch (IOException e)//i guess here " e" should be"exc",but still doesn't
work
{
}
if (line!=null && line.length>0) {
try {
x = Float.parsefloat(line);
} catch (NumberFormatException e)// i guess here " e" should be"exc"
{
}
avatar
st
2
怎么不能用了?

【在 w*******u 的大作中提到】
: 我发现有个网友写过,但不能用.本人刚刚接触java,谢谢大家帮忙!!!!
: float x = 0.0;
: String line = null;
: try {
: line = System.in.readLine();
: }catch (IOException e)//i guess here " e" should be"exc",but still doesn't
: work
: {
: }
: if (line!=null && line.length>0) {

avatar
w*u
3
when i complie it,the computer said:
% javac Bookentry.java
Bookentry.java:47: Type expected.
try {
^

: 【 在 williamyu (williamyu) 的大作中提到: 】
doesn't

【在 st 的大作中提到】
: 怎么不能用了?
avatar
st
4
it seems to be basic java problem, read basic java sample and tutorial first.

【在 w*******u 的大作中提到】
: when i complie it,the computer said:
: % javac Bookentry.java
: Bookentry.java:47: Type expected.
: try {
: ^
:
: : 【 在 williamyu (williamyu) 的大作中提到: 】
: doesn't

avatar
f*t
5

}
~~~~~~~~~~~~~~~~~~~~~
readLine() is not InputStream member function, belongs BufferedReader()
order you can use read()
doesn't

【在 st 的大作中提到】
: it seems to be basic java problem, read basic java sample and tutorial first.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。