In some cases the programmer thinks it is an exception, and the JVM appears to be normal, such as a negative age, so in this case we need to create and throw the exception manually, which requires a throw.
Exception e = new Exception ("Age Exception");//Create exception Object
Throw e;//throws an exception
Objects created and thrown by the programmer themselves must be handled appropriately by throws or try{}, catch{}.
If the exception is thrown to the top, no catch will display the exception information on the front level. When the code in the try{} block generates an exception, the code in the try{} block is interrupted and captured by the catch{} block to the resulting exception, and the code behind the try{}, catch{} is still executed normally. If the two exceptions belong to an inheritance relationship, they should be processed in order from child to parent.
Since Java has a garbage collector, there is no need to deal with the problem of memory recycling in exception handling, but there are still some resources that need to be handled by programmers, such as files, network connections, and pictures, which can be try{}, catch{} and finally{} blocks to clean up the program. Regardless of whether an exception occurs in the try{} block, the code in the finally{} block is bound to be executed.
Usually in a method (class) declaration through the throws declaration method (class) may throw exception information, and in the method (class) through the throw declaration of a specific exception information; Throw can only be used to throw an exception, and throws may throw multiple exceptions, such as: throws exception1,exception2{}.
Java Exception related knowledge