throws IOException的意义

910 阅读1分钟

可以去掉throws IOException 如果主方法里 没有会导致IOException的语句

throws IOException 不是跟try catch一起用的 当方法里一个语句产生了IOException

如果你用的try catch 那么这个异常是在这个方法中被捕获

如果 你用的throws IOException 那么可以不写try catch语句 这个异常被抛到方法外 在这个方法外被捕获