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

  • The Java Workshop
  • David Cuartielles Andreas G?ransson Eric Foster Johnson
  • 202字
  • 2021-06-11 13:05:25

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.

主站蜘蛛池模板: 邯郸县| 沈阳市| 长岛县| 应城市| 青冈县| 德昌县| 武乡县| 古丈县| 峨山| 岱山县| 郎溪县| 镇康县| 辽中县| 墨玉县| 万安县| 砀山县| 稷山县| 凤阳县| 定襄县| 新丰县| 营山县| 二手房| 酒泉市| 青铜峡市| 垣曲县| 宽甸| 裕民县| 忻城县| 双牌县| 施甸县| 兴化市| 共和县| 简阳市| 深圳市| 烟台市| 虎林市| 秀山| 乐昌市| SHOW| 五指山市| 星子县|