try{Integer.parse("Abhishek");}
catch(NumberFormatException e){}
catch(Exception e){}
If for the above piece of code, if NumberFormatException occurs, it will immediatly go to the catch cause of NumberFormatException. But I am not creating any instance of the NumberFormatException… , then where it is getting created.
Is it like –
As soon as any exception occurs, internally JVM checks the type of exception and internally one instance of that particular Exception type is getting created and once it registers or finds any matching type in the catch hierarchy, it goes to that loop
That method will throw a NumberFormatException if the String cannot be parsed into an int. This is documented in the Javadoc.
More or less…
This does not really go all that deep into JVM internals, though. Integer#parseInt is implemented in Java, just like your own program. You can look at the source code if you are interested.