自定义异常类,代码还不是很明白,先存着以后参考。

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();
}
} }

最新文章

  1. MFC去掉标题栏
  2. 机械大楼电梯控制项目软件 -- github团队组建
  3. C语言中system()函数的用法总结(转)
  4. Awesome Python
  5. 在PHPstorm编辑器中配置git环境
  6. Oracle数据库作业-4 查询
  7. LINUX命令之ETHTOOL用法详解
  8. modsecookie
  9. slivelight5和数据库交互
  10. 【转】 iOS Provisioning Profile(Certificate)与Code Signing详解
  11. javascript:DOM自定义属性的妙用
  12. Android在浏览器启动APP
  13. log4go的精确定时程序(带自动延迟补偿)
  14. eclipse中将本地项目上传到svn库
  15. C# 指定父層級目錄
  16. 【ASP.NET Core快速入门】(五)命令行配置、Json文件配置、Bind读取配置到C#实例、在Core Mvc中使用Options
  17. SuperMap GIS资料-----云与Web端技术资料集锦
  18. 交叉编译ffmpeg(hi3520d)
  19. 微信小程序中的app.js-清除缓存
  20. POJ 1064 Cable master (二分法+精度控制)

热门文章

  1. 数据库聚焦与非聚焦索引 事务处理 redis innodb引擎(九)
  2. Linux-&gt;ZooKeeper开机启动的俩种方式
  3. Linux-&gt;Ubuntu下配置telnet环境
  4. windows10 蓝牙(Bluetooth&#174;)设备删除失败解决方案
  5. php解决高并发设想
  6. web.config如何实现301跳转
  7. 沉淀,再出发:Git的再次思考
  8. 如何将程序添加到Windows桌面右键菜单
  9. 入门学习webpack笔记
  10. django get_object_or_404