here is a code:
try {
FileOutputStream fout=new FileOutputStream("path");
javaClassFun(url,fout);
fout.close();
} catch (MalformedURLException ex) {
System.err.println("Invalid URL"+ex);
} catch (IOException e) {
System.err.println("Input/Output error"+e);
}
when i cut the last catch block and paste it after try block it gives unreachable catch block error. I want to know what is the reason behind this.
Exceptionis thrown, thecatchblock checks whether the thrown exception is an instance ofException typeincatchblock and leaves it insidecatchblock. In your case, the catch block withIOExceptionswallow allIOExceptionand its subtypes. i.e.MalformedUrlException