Can not underestimate this simple finally, seemingly simple problems behind, but hidden countless mystery. Next I will take you step-by-step to uncover this finally mysterious veil.Problem Analysisfirst of all, let me ask you a question: Finally
There is a return statement in the try and finally block where no exception is thrown in the 1:try block[Java]View PlainCopy
Public static int noexception () {
int i=10;
try{
System.out.println ("I in Try block is" +i);
return-I.;
}
1.Java ExceptionIn the process of using computer language for project development, even if the programmer writes the code perfectly, there are still some problems in the running of the system, because many problems can not be avoided by the code,
1. system. configuration. configurationsettings. Expired ettings "is out of date [. net2.0 ]:
"System. configuration. configurationsettings. deleettings" is out of date: "This method is obsolete, it has been replaced by system. Configuration!
Java exception in-depth research and analysis, Java in-depth research and analysis
The content of this article belongs to the scope of basic knowledge research. Do not think that the exceptional knowledge can be mastered after reading this article.
JAVA exception and Exception Handling Methods
Exception
This is my teacher's preference: that is to say, I will show you a picture as soon as I come up -_-
This is one:
Exception classification chart
Come on, there is a common exception with
First, prefaceThere was a question in the interview some days ago: Public class Test { Public Static void Main (string[] args) { try { return; } finally { System.out.println ("finally ...");}}
try{} has a return statement, then the code in the finally{} immediately following this try will not be executed, when executed, before or after the return?Will certainly execute. The code for the finally{} block only contains a try{} block that
The connection between error and exception
Inheritance structure: Both error and exception inherit from Throwable,runtimeexception inherited from exception.
The error and runtimeexception and their subclasses are called unchecked
Author: MaverickBlog:Http://blog.csdn.net/zhaohuabing reprinted please indicate the source1 IntroductionBefore the emergence of the Java language, traditional Exception Handling Methods mostly use return values to identify exceptions in programs.
Conclusion:1, regardless of the occurrence of wood anomalies, finally block code will be executed;2, when there is return in the try and catch, finally will still execute;3, finally is executed after the return of the expression after the operation (
Important Conclusions:1. The code in the finally block executes whether or not an exception occurs2. When there is a return in the try and catch, finally will still execute3.finally is performed after the expression operation after return (at this
Conclusion:1, regardless of the occurrence of wood anomalies, finally block code will be executed;2, when there is return in the try and catch, finally will still execute;3, finally is executed after the return of the expression after the operation
The Java exception handling mechanism relies mainly on try,catch,finally,throw,throws five keywords. The try keyword is immediately followed by a block of code enclosed in curly braces, called the try block. Similarly: The following is also known
http://blog.csdn.net/kavensu/article/details/8067850
Conclusion:1, regardless of the occurrence of wood anomalies, finally block code will be implemented;2. Finally still executes when there is return in try and catch;3, finally is after the
Turn from: http://blog.csdn.net/kavensu/article/details/8067850
Directory:
Conclusion Example Final conclusion
ConclusionsThe code executes in the finally block, regardless of the occurrence of the wood, and finally still executes when there is
Executing a try before executing a statement in Finally,catch may affect the execution of finallyfinally block, you can clean up any resources that are allocated in a try block, and you can run code even if an exception occurs in the try block."
In programming, exception handling is a very critical and important part. The exception-handling framework of a program directly affects the quality of the entire project and the cost and difficulty of subsequent maintenance. Imagine if a project
Learn Java students pay Attention to!!!The learning process encountered any problems or want to acquire learning resources, Welcome to join the Java Learning Exchange Group Number: 618528494 we learn java! together
In programming, exception
See a good article about exception handling:The Java exception handling mechanism relies mainly on try,catch,finally,throw,throws five keywords.The Try keyword is immediately followed by a block of code enclosed in curly braces, called the try block.
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.