JAVA基础 - 自定义异常类
2024-10-21 04:15:35
自定义异常类,代码还不是很明白,先存着以后参考。
package week6; class ScoreException extends Exception { private static final long serialVersionUID = 1L; public ScoreException() {
super();
} public ScoreException(String str) {
super(str);
} } class Student { private String name;
private int score; public Student() {
super();
} public Student(String name, int score) throws ScoreException {
super();
this.name = name;
if(score >= 0 && score <= 100) {
this.score = score;
}else {
throw new ScoreException("Wrong Score");
}
} public String showName() {
return this.name;
}
public int showScore() {
return this.score;
}
} public class Week6 { public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Student LiMing = new Student("Liming",-1);
}catch(ScoreException e) {
e.printStackTrace();
}
} }
最新文章
- MFC去掉标题栏
- 机械大楼电梯控制项目软件 -- github团队组建
- C语言中system()函数的用法总结(转)
- Awesome Python
- 在PHPstorm编辑器中配置git环境
- Oracle数据库作业-4 查询
- LINUX命令之ETHTOOL用法详解
- modsecookie
- slivelight5和数据库交互
- 【转】 iOS Provisioning Profile(Certificate)与Code Signing详解
- javascript:DOM自定义属性的妙用
- Android在浏览器启动APP
- log4go的精确定时程序(带自动延迟补偿)
- eclipse中将本地项目上传到svn库
- C# 指定父層級目錄
- 【ASP.NET Core快速入门】(五)命令行配置、Json文件配置、Bind读取配置到C#实例、在Core Mvc中使用Options
- SuperMap GIS资料-----云与Web端技术资料集锦
- 交叉编译ffmpeg(hi3520d)
- 微信小程序中的app.js-清除缓存
- POJ 1064 Cable master (二分法+精度控制)
热门文章
- 数据库聚焦与非聚焦索引 事务处理 redis innodb引擎(九)
- Linux->;ZooKeeper开机启动的俩种方式
- Linux->;Ubuntu下配置telnet环境
- windows10 蓝牙(Bluetooth&#174;)设备删除失败解决方案
- php解决高并发设想
- web.config如何实现301跳转
- 沉淀,再出发:Git的再次思考
- 如何将程序添加到Windows桌面右键菜单
- 入门学习webpack笔记
- django get_object_or_404