F
fu_qi_ming
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
class java02
{
public static void main(String[] args)
{
int n,ch,d=0;
for (n=0;(ch=System.in.read())!=-1;n++)
{
if(ch>='0' &&
ch<='9') d++;
}
System.out.println("/n"+n+"个字符");
System.out.println(d+"个数字");
}
}
编译后报错:
java02.java:6: unreported exception java.io.IOException;
must be caught or declared to be thrown
for (n=0;(ch=System.in.read())!=-1;n++)
^
1 error
class java02
{
public static void main(String[] args)
{
int n,ch,d=0;
for (n=0;(ch=System.in.read())!=-1;n++)
{
if(ch>='0' &&
ch<='9') d++;
}
System.out.println("/n"+n+"个字符");
System.out.println(d+"个数字");
}
}
编译后报错:
java02.java:6: unreported exception java.io.IOException;
must be caught or declared to be thrown
for (n=0;(ch=System.in.read())!=-1;n++)
^
1 error