怎么从键盘输入整数或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"
{
}
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"
{
}