Checked vs unchecked exceptions
| Checked exception | Unchecked exception |
|---|---|
final Path
sourcePath = Paths.get("/tmp/test.txt"),
destPath = Paths.get("/tmp/copy.java");
// Compile time error:
// Unhandled java.io.IOException
Files.copy(sourcePath, destPath);
...
|
final String s = null;
// Compiles smoothly
System.out.println(s.length());
|
Recommended readings:
