jjzjj

Unreported

全部标签

java - 修复错误 : Unreported Exception InterruptedException

我是Java新手。我刚刚在搜索如何让Java程序等待,它说使用Thread.sleep()方法。但是,当我这样做时出现错误:error:unreportedexceptionInterruptedException;mustbecaughtordeclaredtobethrown我通过在方法声明中添加throwsInterruptedException来解决这个问题,现在它可以工作了。但是,调用方法的时候,又报错了。人们说要使用throwandcatchblock,但我还不确定该怎么做。有人可以帮我吗?无论如何,Draw.java的代码(使用sleep()方法):packagegrap

java - 错误 : unreported exception FileNotFoundException; must be caught or declared to be thrown

这个问题在这里已经有了答案:Whatdoes"error:unreportedexception;mustbecaughtordeclaredtobethrown"meanandhowdoIfixit?(1个回答)关闭5个月前。我正在尝试创建一个将字符串输出到文本文件的简单程序。使用我在此处找到的代码,我将以下代码放在一起:importjava.io.*;publicclassTesting{publicstaticvoidmain(String[]args){Filefile=newFile("file.txt");file.getParentFile().mkdirs();Prin

java - 错误消息 "unreported exception java.io.IOException; must be caught or declared to be thrown"

这个问题在这里已经有了答案:Whatdoes"error:unreportedexception;mustbecaughtordeclaredtobethrown"meanandhowdoIfixit?(1个回答)关闭5个月前。错误:filecontent.java:15:unreportedexceptionjava.io.IOException;mustbecaughtordeclaredtobethrownshowfile();^filecontent.java:78:unreportedexceptionjava.io.IOException;mustbecaughtordec