Read Catalogue
First, Exception introduction
Second, try-catch-finally statement
Iii. Throw and Throws keywords
Four, the exception chain in Java
V. Concluding remarks
Java exception and exception handling back to top
Exceptions are problems that may arise during the execution of a program, and C + + exceptions are special cases that occur when a program is run, such as an attempt to divide by 0. Exceptions provide a way to transfer program control, with C + +
1, Exception Overview:What is an exception?An exception is a class that describes the abnormal behavior that occurs when a program runs.The origin of the exception:The anomaly originates from the description of the problem in real life, the problem
I. Overview of exceptionsException handling has become one of the criteria for measuring the maturity of a language, and current mainstream programming languages such as C + +, C #, Ruby, Python, and so on, provide exception handling mechanisms.
How many 1.java keywords (keyword) are there?51+2 a reserved word = 53 Keywords (java keywords are lowercase!!) )What is the reserved word for 2.java (reserve word)? Question: What are the differences?2 reserved wordsReserved words in the Java
Keywords and reserved words http://www.cnblogs.com/wwxbi/p/4292170.htmlAccess controlPrivate protected publicClass, method, and variable modifiersAbstract class extends final implements interface native new static
1, exception: is an abnormal condition that occurs during runtime. in Java, the object is described and encapsulated in the form of a class. A class that describes an unhealthy condition is called an exception class. in combination with normal
Java Exception Handling summaryexception handling is a very important aspect of program design, but also a major difficulty in programming, from C, you may already know how to use if...else ... To control the anomalies, perhaps spontaneously,
First, how to properly close resources using finallyThe finally block is always executed regardless of whether the program is abnormal, so it is often used to close the physical resource, ensuring that the resource is always closed.ImportJava.io.*;
What are the 1.Java keywords (reference URL: 1.https://www.cnblogs.com/chenglc/p/6922834.html2.https://zhidao.baidu.com/question/89449594.html)1.1) Access control: Private (private), protected (protected), public (common), default (sometimes
1. Try-catch statement
In Java, exceptions are caught by Try-catch statements. Its general grammatical form is:
The try {
//The program code that may have an exception can
catch (Type1 id1) {
//catch and dispose of the exception type
A Java exception is an object that describes the condition of an exception (that is, an error) that occurs in a code snippet. When an exception occurs, an object representing the exception is created and thrown (throw) in the method that caused the
Typically, statements are executed sequentially. However, in addition to the simplest programs, sequential execution is often not sufficient. To do this, C + + defines a set of control-flow statements that allow for conditional execution or repeated
When exceptions are thrown, the usual method of execution will be a steep non-linear steering. Depending on how the method is encoded, an exception can even cause the method to return prematurely. This is a problem in some ways. For example, if a
2) flow control and exception handling
Objective 1)
The Write code using if and switch statements and identify legal argument types for these statements.
· Unreachable statements produce a compile-time error.
while (false) {x = 3;}//won ' t compile
Specification 4.1 iterator block
An iterator block (iterator blocks) is a block that produces an ordered sequence of values. The difference between an iterator block and a normal statement block is one or more yield statements that appear.
The
Java's exception handling mechanism can make the program have excellent fault tolerance and make the program more robust. The so-called exception is the problem that prevents the current method or scope from continuing to execute, and when the
Anomaly Classification Plots:Throwable|--error serious problems that we do not deal with.|--exception|--runtimeexception run-time exception, we need to fix the code|--non-RuntimeException compile-time exception, must be handled, or program
class TemplateYou can use to define a class that defines a specific set of types. Class templates template keyword is followed by a list of angle brackets (<>) attached, defined.Export keyword (exporting keywords)The keyword used to indicate that
For more information, see. NET Exception Handling. NET exception handling.
The next year is approaching. For most programmers, they can be idle for a while now. However, in this free time, they can only argue Which language is better at killing time,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.