import java.io.*;
class Tmp{
public static void main(String btbbb[])throws IOException
{BufferedReader inp=new BufferedReader(new InputStreamReader(System.in)); String s =inp.readLine(); //输入字符串 System.out.println(s);
}
}
这是输入语句,我不明白为什么一定要抛出io异常,还是说有别的方式,能不抛出吗?
class Tmp{
public static void main(String btbbb[])throws IOException
{BufferedReader inp=new BufferedReader(new InputStreamReader(System.in)); String s =inp.readLine(); //输入字符串 System.out.println(s);
}
}
这是输入语句,我不明白为什么一定要抛出io异常,还是说有别的方式,能不抛出吗?
或者在你的方法里处理该异常
如下
try{
String s =inp.readLine(); //输入字符串
}catch(IOException e){
System.out.println("可耻的出现异常:"+e.toString());
}这样你就可以不在你的main方法后面声明抛出IO异常了.
try{
s =inp.readLine(); //输入字符串
}catch(IOException e){
System.out.println("可耻的出现异常:"+e.toString());
}