java 什么情况下应该在方法中抛出SystemException

2024-11-27 11:38:00
推荐回答(4个)
回答1:

各个Exception之间不同。就好像各个错误不同。Exception是异常的意思。SystemException是应用异常的意思。打个比方还有时间异常,对象异常等等 但是他们都叫异常 所以如果不是很细的话用Exception就可以了。

回答2:

抛出不同的exception就是为了见名知意
如SQLException,就知道肯定是操作数据库的时候出了错
RemoteException 一看就知道是远程方法调用的时候出错了
IOException 一看就知道操作二进制流或文件出错了
等等等等

回答3:

SystemException和XxxError应该都是JVM自己用的吧,最好不用吧。
和普通的Exception没有区别,

回答4:

System exception means some runtime errors have occurred and generally speaking, you don't want to handle them.

Another common type of exception is Application exceptions, that normally are generated by your application's code. You want to handle them properly, since they are from your application's logic.

For instance, if a user want to access resources that are not permitted, you can throw security exception etc.