当前位置:网站首页>Custom exception
Custom exception
2022-07-02 15:32:00 【Killer is not too cold!】
Custom exception
While the program is running , Sometimes when you finish executing a piece of code, you find that the program code is illogical , So we want to return End this code , But the return value type of the method where this code is located is void, So we can't return, So what should we do at this time ? At this time, we can customize an exception , Then actively throw an exception in the method .
The custom exception code is as follows :
/** * @Author zy.xuan * @Date 2022/6/21 14:13 */
public class ComplaintExeception extends RuntimeException {
private String message;
public ComplaintExeception(String message){
this.message = message;
}
@Override
public String toString() {
return message;
}
}

Test custom exceptions , Here's the picture :

边栏推荐
- 面对“缺芯”挑战,飞凌如何为客户产能提供稳定强大的保障?
- Force deduction solution summary 2029 stone game IX
- Libcurl Lesson 13 static library introduces OpenSSL compilation dependency
- Learn the method code of using PHP to realize the conversion of Gregorian calendar and lunar calendar
- 15_Redis_Redis.conf详解
- Mavn builds nexus private server
- yolo格式数据集处理(xml转txt)
- LeetCode_ Sliding window_ Medium_ 395. Longest substring with at least k repeated characters
- 18_ Redis_ Redis master-slave replication & cluster building
- 4. Data splitting of Flink real-time project
猜你喜欢

【网络安全】网络资产收集

Leetcode skimming -- incremental ternary subsequence 334 medium

10_Redis_geospatial_命令

Learn the method code example of converting timestamp to uppercase date using PHP

Redux——详解

FPGA - clock-03-clock management module (CMT) of internal structure of 7 Series FPGA

I made an istio workshop. This is the first introduction

百变大7座,五菱佳辰产品力出众,人性化大空间,关键价格真香

XML Configuration File

Bing. Com website
随机推荐
6.12 企业内部upp平台(Unified Process Platform)的关键一刻
让您的HMI更具优势,FET-G2LD-C核心板是个好选择
Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
How to test tidb with sysbench
Leetcode skimming -- verifying the preorder serialization of binary tree # 331 # medium
LeetCode刷题——去除重复字母#316#Medium
03. Preliminary use of golang
[solution] educational codeforces round 82
Practical debugging skills
Solution of Queen n problem
04.进入云原生后的企业级应用构建的一些思考
04. Some thoughts on enterprise application construction after entering cloud native
13_ Redis_ affair
Oracle primary key auto increment
List set & UML diagram
彻底弄懂浏览器强缓存和协商缓存
Be a good gatekeeper on the road of anti epidemic -- infrared thermal imaging temperature detection system based on rk3568
4. Jctree related knowledge learning
MD5加密
Facing the challenge of "lack of core", how can Feiling provide a stable and strong guarantee for customers' production capacity?