October 2018
Intermediate to advanced
370 pages
9h 15m
English
If the execution of a function can't be completed, an exception can be thrown. The most common causes of this are listed as follows:
The throw keyword is used to interrupt the execution of a current function and to notify a caller about an exceptional event. Let's look at the constructor of the FileInputStream class:
public FileInputStream(File file) throws FileNotFoundException { String name = (file != null ? file.getPath() : null); SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(name); } if (name == null) { throw new NullPointerException ...
Read now
Unlock full access