这个课程的参考视频和图片来自youtube

主要学到的知识点有:

We want to handle the bad Error. (e.g bad input / bugs in program)

  • Error: a type of Exception  

    e.g   File I/O;   User Input, out of control.

An example that handle the wrong input and out of range input.

1. First we creat two java class (IntegerOutOfRangeException and InputMisMatchException)

public class IntegerOutOfRangeException extends Exception {
}
public class InputMisMatchException extends Exception {
}

2. Then we will use try and  catch to catch the exceptions.

try {
i = input.nextint();
if (i < 1 || i > 10) {
throw new integerOutOfRangeException();
}
catch (inputMisMatchException ex){
System.out.println("you did not enter an integer.");
}
catch (integerOutOfRangeException ex){
System.out.println("your input value is out of range.");
}
}

[Java in NetBeans] Lesson 16. Exceptions.的更多相关文章

  1. [Java in NetBeans] Lesson 07. JavaDoc and Unit Tests

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. organize code into packages Create a package if want to make th ...

  2. [Java in NetBeans] Lesson 00. Getting Set-up for Learning Java

    这个课程的参考视频在youtube. 主要学到的知识点有: set up needs Java SE JDK, NetBeans IDE class name should be the same l ...

  3. [Java in NetBeans] Lesson 17. File Input/Output.

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: We want to handle the bad Error. (e.g bad input / bugs in program) ...

  4. [Java in NetBeans] Lesson 15. Sorting and Searching.

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Build in functions in java.util.Collections Need to implement a co ...

  5. [Java in NetBeans] Lesson 09. Switch / If-Else Ladder

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. Nested If-else statement (if-else ladder) /** * 90 and above == ...

  6. [Java in NetBeans] Lesson 06. Custom classes

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Constructors: A special method called when an object of the class ...

  7. [Java in NetBeans] Lesson 05. Method/function

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Define a method:(motivation: write one time, but use it many times ...

  8. [Java in NetBeans] Lesson 04. Class / Objects

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Class: Blueprint for an object. (e.g. dog is a class) Object: cust ...

  9. [Java in NetBeans] Lesson 01. Java Programming Basics

    这个课程的参考视频在youtube. 主要学到的知识点有: Create new project, choose Java Application. one .jar file/ package(.j ...

随机推荐

  1. 【react】---styled-components的基本使用---【巷子】

    一.官网地址 https://www.styled-components.com/ 二.styled-components 1.styled-components 样式化组件,主要作用是它可以编写实际 ...

  2. MySQL-记一次备份失败的排查过程

                山竹来临,窝在家里整理个人文档.        本篇文章主要讲解排查问题的思路,涉及linux 删除文件的原理.实例误删数据恢复.MySQL实例初始化参数优先级别等,虽然涉及知 ...

  3. 坑!vue.js在ios9中失效

    坑!vue.js在ios9中失效! 接到实现,在移动端生成一个分享链接,分享到微信,在微信中打开,加入! 好,用vue实现----------------------->写代码--------- ...

  4. js常用校验

    //验证金钱数字obj.regexMoney = function (money) { var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)| ...

  5. HDU 4347 - The Closest M Points - [KDTree模板题]

    本文参考: https://www.cnblogs.com/GerynOhenz/p/8727415.html kuangbin的ACM模板(新) 题目链接:http://acm.hdu.edu.cn ...

  6. [No000011C]使人醒悟的生活中的定律

    1.     墨菲定律 我们在事前应该是尽可能想得周到.全面一些,如果真的发生不幸或者损失,就笑着应对吧,关键在于总结所犯的错误,而不是企图掩盖它. 2.     羊群效应 对他人的信息不可全信也不可 ...

  7. 微信、QQ群短文本聊天语料总结

    在文本分类任务中,语料的特性千差万别,我们需要找到适合模型并抓住数据的特性,最终才能得到较好的model.最近在文本类别标注任务,就是给文本打标签确定该文本的类别.这是一个很费人工的过程,需要认真仔细 ...

  8. 动画支持的一些keypath

    transform.scale = 比例轉換 transform.scale.x = 闊的比例轉換 transform.scale.y = 高的比例轉換 transform.rotation.z = ...

  9. python-mysql数据库导表存excel后发邮件(实例2)

    需求:用户输入mysql数据库中某表名,将此表导入到excel中,将导出文件以邮件形式发出 设计思路: 1连接数据库 2读取表头(cur.description--获取表头,函数返回二维元组,采用列表 ...

  10. Type Operators instanceof is used to determine whether a PHP variable is an instantiated object of a certain class/a class that implements an interface

    w 0-instanceof is used to determine whether a PHP variable is an instantiated object of a certain cl ...