eWhile catching exceptions is this necessary to check if the error message is not null to avoid null pointer exception? Another words, is the if (e!=null) part needed? or e is always not null?
try {
...
} catch(Exception e) {
if (e != null) {
System.err.println("Error: " + e.getMessage());
}
}
Anything that gets thrown must be a subclass of
Throwable, and your catch will only catch things that are a subclass ofException. Therefore you can neither throw nor catchnull, therefore checking for nullality is not necessary. If you usethrow nullor throw a variable that contains null then it will throw aNullPointerException.