[Notes] for custom exception of understanding (Java)

Originally, the original exception is non-manually, automatically thrown.

 

Understanding custom exception, we found that information only:

  • Who inherited that its own count which exception;
  • Its information, such as an ID, this seemingly is optional;
  • It is information that can be passed

 

Not missing, then it is that the three of us.

 

At this point, he appeared confused:

Abnormal most critical is that it would like to express some kind of mistake or error of some sort, so at least the Exception class which contains "what point does this anomaly that was thrown out when" this level of information, right?

There's no exception in Java? ? ? ?

 

That computer how to know about this new definition of abnormal, "it's kind of abnormality" information?

I obviously did not tell it ah? ? ? ?

 


This critical information in the code can be considered a fact reflected, but seemingly only concrete expression:

That is, at throwthe time this information was only told to the computer.

 

If you want to set up one breath "should throw a custom exception Shashi Hou", then this means that the JVM can automatically thrown.

Manual thrown exist, it seems, make the rules abstractly tells the computer throws an exception of this kind of work, become unnecessary - probably because existing rules are set automatically throw good enough? ......

In short, I am now certain is that, if not since the exception in the class is given on the definition of a computer "should decide how to rule whether Han Han Han regarded as such an exception" of information, this information can be use throwwas specifically told to the computer: there is only throwtime before they throw the custom exception.

- that is, the rule is not automatically thrown care of user-defined abnormal.

 

(This is a pity, unable to come up with some terrible things, such as the number of bad naming conventions abnormal then further upgraded compiler specification for the programmer to be counted when compiling ...... In fact, this idea is similar to compiling want to modify rules, of course, can do to more stringent changes.

- I had to understand the "custom exception" it is to be able to do to get this kind of thing /_>\. . . . )

Guess you like

Origin www.cnblogs.com/senwren/p/Throwable_selfSet_in_Java.html