java捕获异常catch 12.6持续更新

java捕获所有异常 catch
今天来讲的是exception中的捕获所有异常
在出现异常后通常是只写一个异常来捕获所有异
常。实现的原理在于捕获的是当前小异常的基类
Exception 类(事实上还有很多异常基类但
Exception是同编程活动相关的基类)
Exception 说来也挺有趣它作为一个编程活动相
关的类但它的方法少之又少,于是你又在想为什么
需要这样一个类来呢都没啥用?要它来有屁用实际
上它本身是不具有太多具体的信息,但是用的时候
我们大多部分用它的基类 throwable 类,我们又不
得抛弃 exception 因为它是跟编程相关的基类,
exception 又继承于throwable类,以下是 exception
常用方法(实际来源于 throwable类)
String getMessage();获取详细信息
String getLocalizeMessage();用本地语言表示信息
String toString()返回对 throwable 类的描述注意不
是描述的 exception 类而是 throwable 类
Void printStackTrace()调用栈轨迹
Void printStackTrace(PintSteam)调用栈轨迹
Void printStackTrace(java.io.printwritet)调用栈
轨迹
k
often. The principle of implementation is that it catches the base class of the current small exception
Exception class (In fact, there are many exception base classes but.)
Exception is the base class related to programming activities)
Exception is also quite interesting to say that it is a programming activity phase
There are very few ways to close the class, so you wonder why
What is the use of needing such a class? Want it to have farts with reality
On itself it does not have much specific information, but when used
We mostly use its base class throwable class, which we don’t
I have to abandon exception because it is a programming-related base class.
exception is inherited from the throwable class, and the following is exception
Common methods (actually from the throwable class)
String getMessage(); Get the details
String getLocalizeMessage(); Information is expressed in the local language
String toString() returns a description of the throwable class note no
is the exception class described but a throwable class
Void printStackTrace() calls the stack trace
Void printStackTrace (PintSteam) calls the stack trace
Void printStackTrace (java.io.printwritet) call stack
locus



child

75
Date and time
Text box Document part WordArt drop cap
formula
symbol
numbering
object
text
symbol
When you see that something interesting is happening again, think about it
Ever heard such a sentence? All classes inherit from the object class
Then you once again wonder if the exception class is also inheritance
The object exception class is something special and it can use object
Is there a normal way to inherit? The answer is yes, getclass is one
A good method returns something that represents the type of object, which can then be used
getname() queries the class object for information that it contains
Catch(exception e){
e.getMessage();
e.getLocalizeMessage();
e.toString();
e.getclass().getname();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值