电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

实验指导书实验异常处理与异常类样本

实验指导书实验异常处理与异常类样本_第1页
1/13
实验指导书实验异常处理与异常类样本_第2页
2/13
实验指导书实验异常处理与异常类样本_第3页
3/13
下载后可任意编辑实验 7 异常处理与异常类一. 实验目的及实验环境 1 理解 Java 异常的基本概念和处理机制。 2 掌握 Java 异常处理的方法( 抛出和捕获异常; try、 throw、 throws、 catch 语句和 finally 的用法) 3 理解异常类的作用, 掌握创立异常类的方法。二. 实验内容 1 基本内容( 实验前请及时熟悉如下相关内容) 1) Java 的异常处理机制2) 异常类的应用3) 常见的异常(除数为零等)4) 多异常处理5) 由方法抛出异常6) 必须要捕获的异常 2 综合实验: 2.1 (Y. Daniel Liang英文版第10版P488: 12.2* (InputMismatchException)) (Y. Daniel Liang英文版八版P456: 13.2*) (NumberFormatException) Write a program that prompts the user to read two integers and displays their sum. Your program should prompt the user to read the number again if the input is incorrect.2.2 (Y. Daniel Liang英文版第10版P488: 12.3* ) (Y. Daniel Liang英文版八版P456: 13.3*) (ArrayIndexOutBoundsException) Write a program that meets 下载后可任意编辑the following requirements:■ Create an array with 100 randomly chosen integers.■ Prompt the user to enter the index of the array, then display the corresponding element value. If the specified index is out of bounds, display the message Out of Bounds.2.3 (Y. Daniel Liang英文版第10版P488: 12.4* ) (Y. Daniel Liang英文版八版P456: 13.4*) (IllegalArgumentException) Modify the Loan class in Listing 10.2 to throw IllegalArgumentException if the loan amount, interest rate, or number of years is less than or equal to zero.2.4 (Y. Daniel Liang英文版第10版P488: 12.5* ) (Y. Daniel Liang英文版八版P456: 13.5*) (IllegalTriangleException) Exercise 11.1 defined the Triangle class with three sides. In a triangle, the sum of any two sides is greater than the other side. The Triangle class must adhere to this rule. Create the IllegalTriangleException class, and modify the constructor of the Triangl...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

实验指导书实验异常处理与异常类样本

您可能关注的文档

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部