If i write things like this :
public static void main(String[] args) {
try {
} catch (MalformedURLException e) {
e.printStackTrace()
};
}
Java compiler shows compilation error at catch clause of MalformedURLException
. If i insert line
URL url = new URL("HI");
in try block , complaining stops. I thought java must be binding these checked exceptions with package. Then i tried another class of java.net package by inserting " CookieManager manager = new CookieManager();
" only in try block. Compilation error again starts.
So how does JVM bind these checked exceptions with java classes for compilation time errors like this?