p267~p270:

1、一个方法不仅需要告诉编译器将要返回什么值,

要告诉编译器有可能发生什么错误(以便在错误发生时用妥善的方式处理错误)。

2、方法应该在首部声明所有可能抛出的异常。

3、方法抛出异常对象后:运行时开始搜索异常处理器,以便知道如何处理异常对象。

4、一个方法必须声明所有可能抛出的受查异常

5、注意:子类覆盖超类方法只能抛出更特定的异常,或者根本不抛出任何异常。

6、如何抛出异常。先声明受查异常,然后在适当的地方添加 throw new Exception();语句。

(可以加上字符串参数,更加细致的描述异常)更通用的来说,对于一个已经存在的异常类:

1)找到一个合适的异常类。 2)创建这个类的一个对象。 3)将对象抛出。

Core Java 2的更多相关文章

  1. applet示例 WelcomeApplet.java <Core Java>

    import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.Font; import java.awt.Grap ...

  2. Core Java Volume I — 1.2. The Java "White Paper" Buzzwords

    1.2. The Java "White Paper" BuzzwordsThe authors of Java have written an influential White ...

  3. Core Java Volume I — 4.7. Packages

    4.7. PackagesJava allows you to group classes in a collection called a package. Packages are conveni ...

  4. Core Java Interview Question Answer

    This is a new series of sharing core Java interview question and answer on Finance domain and mostly ...

  5. Core Java 学习笔记——1.术语/环境配置/Eclipse汉化字体快捷键/API文档

    今天起开始学习Java,学习用书为Core Java.之前有过C的经验.准备把自己学习这一本书时的各种想法,不易理解的,重要的都记录下来.希望以后回顾起来能温故知新吧.也希望自己能够坚持把自己学习这本 ...

  6. Core Java读书笔记之String

    Java里面的String Conceptually, Java Strings are sequences of Unicode characters. Java里面的String都是Unicode ...

  7. Top 25 Most Frequently Asked Interview Core Java Interview Questions And Answers

    We are sharing 25 java interview questions , these questions are frequently asked by the recruiters. ...

  8. Difference Between Arraylist And Vector : Core Java Interview Collection Question

    Difference between Vector and Arraylist is the most common  Core Java Interview question you will co ...

  9. Core Java (十一) Java 继承,类,超类和子类

    Core Java (十一) Java 继承,类,超类和子类 标签: javaJavaJAVA 2013-01-22 17:08 1274人阅读 评论(0) 收藏 举报  分类: java(58) 读 ...

  10. Core Java的那点事儿之ArrayList

    Core Java的那点事儿之ArrayList 万丈高楼平地起,Java基础要拿起.今天就从我看的Core Java里找了些小基础点来分享一下. 首先隆重介绍一下专业级龙套演员---Employee ...

随机推荐

  1. is_file file_exists microtime performance

    对项目中旧代码的疑问 } elseif (substr($class_name, 0, 6) == 'OAuth2') { $file_name = $C->INCPATH . 'classes ...

  2. Metasploit services

    漏洞挖掘/漏洞分析-- Cve.mitre.org www.corelan.be----geek of pentesters http://wrox.cn/article/100048133/    ...

  3. render, render_to_response, redirect,

    自django1.3开始:render()方法是render_to_response的一个崭新的快捷方式,前者会自动使用RequestContext.而后者必须coding出来,这是最明显的区别,当然 ...

  4. flask操作简章

    https://blog.csdn.net/u011054333/article/details/70151857

  5. OKEx货币对价格数量长度及精度

    长度 precisions = [["bch_btc","0.001","0.00000001"], ["ltc_btc" ...

  6. 【Loadrunner】【浙江移动项目手写代码】代码备份

    vuser_init(){        lr_start_transaction("login"); web_url("10.78.224.136:8080" ...

  7. java获取屏幕密度

    方法1: float xdpi = getResources().getDisplayMetrics().widthPixels;float ydpi = getResources().getDisp ...

  8. Linux 线程实现机制分析 Linux 线程模型的比较:LinuxThreads 和 NPTL

    Linux 线程实现机制分析 Linux 线程实现机制分析  Linux 线程模型的比较:LinuxThreads 和 NPTL http://www.ibm.com/developerworks/c ...

  9. 十四、springboot全局处理异常(@ControllerAdvice + @ExceptionHandler)

    1.@ControllerAdvice 1.场景一 在构建RestFul的今天,我们一般会限定好返回数据的格式比如: { "code": 0, "data": ...

  10. hdu1671Phone List(字典树)

    #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h&g ...