官术网_书友最值得收藏!

Introduction

Exceptions are not errors, or, more accurately, exceptions are not bugs, even if you might perceive them to be when they crash your programs. Exceptions are situations that occur in your code when there is a mismatch between the data you are handling and the method or command you are using to process it.

In Java, there is a class that is dedicated to errors. Errors are unexpected situations that affect programs on the Java Virtual Machine (JVM) level. For example, if you fill-up the program stack through an unconventional use of memory, then your whole JVM will crash. Unlike errors, exceptions are situations that your code, when properly designed, can catch on the fly.

Exceptions are not as drastic as errors, even if the result for you, the developer, will be the same—that is, a non-working program. In this chapter, we are inviting you to make your programs crash by intentionally provoking exceptions that you will later learn how to catch (that is, handle) and avoid. Depending on how you develop the catch mechanism, you can decide whether to get your program to recover and continue operating or to gracefully end its execution with a human-readable error message.

主站蜘蛛池模板: 武义县| 沧州市| 东乡县| 芜湖县| 黄大仙区| 汉川市| 普格县| 阿勒泰市| 龙江县| 肥西县| 常宁市| 玛曲县| 吐鲁番市| 静安区| 桦南县| 建昌县| 长丰县| 罗源县| 南安市| 民县| 四川省| 平泉县| 新竹县| 龙州县| 恭城| 新兴县| 石门县| 土默特右旗| 扎赉特旗| 衡东县| 丰镇市| 安阳县| 尚义县| 南岸区| 宣城市| 敦煌市| 嵊州市| 玉龙| 突泉县| 沂源县| 澄江县|