为什么有些程序必须需要捕获异常呢?(也就是try,catch等语句)
我在运行程序是就出现了如下:
unreported exception lotus.domino.NotesException;must bi caught or
declared to be thrown
我在运行程序是就出现了如下:
unreported exception lotus.domino.NotesException;must bi caught or
declared to be thrown
catch(Exception e)
{
}进行捕捉
public static void main(String args[]){
try{
Session s = NotesFactory.createSession("host","username","password");
Database db = s.getDatabase("","thedatabase");
View viw=db.getView("aaa");
System.out.println(viw);
}
catch(Exception e)
{
e.printStackTrace();
}
}}请大家给我分析下这个程序为什么必须要用到try和catch,如果不用就报上面的错误!
大家给我指点下,该程序里哪个调用了抛出异常的方法?
谢谢了
怎么,查不到么?你用的类都没有文档的?
getDatabase( " ", "thedatabase "); //与数据库建立连接可能会出现异常
所以,你必须要考虑对这些异常进行处理,不然转移它们也可以!
如果不处理的话在运行时就出现异常。而未检查异常可以抛出也可以不理他。