当前位置:网站首页>异常类
异常类
2022-07-21 17:52:00 【weixin_50179990】
1、异常是什么?
当你常识将字符串里的字母或汉字转换为int类型的时候。异常就来了。
2、自定义异常类
创造一个异常类的子类,继承异常类后在子类的构造器中引用父类方法。
再创造一个类,在类中定义一个方法并用throws抛出异常类,在方法中定义几个形参,在方法中依据形参建立几个条件,不满足条件的再用throws抛出异常,将异常的原因,写在异常类的形参里。
最后在主方法里引用具有方法的那个类的对象,在try…catch里引用这个对象的方法。
自定义类新建完成
边栏推荐
- CAN通信协议(一)
- position: -webkit-sticky; /* for Safari */ position: sticky;
- 【幹貨】知識共享的障礙及解决方法
- "Everything is interconnected, enabling thousands of industries", the 2022 open atom global open source summit openatom openharmony sub forum is about to open
- 八大(变量)基本类型
- 腾讯云免费升级。
- 基于RedisTemplate封装的工具类
- 【ACM/二分】二分清晰入门级讲解
- go-zero微服务实战系列(三、API定义和表结构设计)
- 模拟实现库函数memcpy--复制内存块。详细理解内存重叠及精准复制问题
猜你喜欢
"Everything is interconnected, enabling thousands of industries", the 2022 open atom global open source summit openatom openharmony sub forum is about to open
流
Ctrip spark multi tenant query service evolution, Apache Kyuubi can be expected in the future
Go zero micro service practical series (III. API definition and table structure design)
Leetcode83 & leetcode82: delete duplicate elements in the sorting linked list
Introduction to class loader
QT configuration opencv (II): successful
推荐系统-协同过滤在Spark中的实现
Leetcode342:4 power
Seven parameters of thread pool
随机推荐
jupyter notebook中切换虚拟环境
Leetcode342:4 power
遇到的问题记录
QT configuration opencv (II): successful
飞机大战分析及代码
conda 常用功能记录
单细胞论文记录(part18)--Spectral clustering based on learning similarity matrix
odoo+测试
“万物互联,使能千行百业”,2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛即将开幕
Seven ways to create thread pools
遇到的一个问题:
基于RedisTemplate封装的工具类
浏览器获取cookie失败,浏览器解决方案
Leetcode-468: verify IP address
h5py快速入门指南
单细胞论文记录(part17)--Integrating sc transcriptomic data across different conditions, tech and species
String str = new String(“abc“) 到底创建了几个变量?
数组
The difference between delete and truncate in SQL
Union keyword in SQL