Sorry if this is a very basic question
As for my understanding if you have a method that throws an exception, you are required to catch it (or throw it) whenever you will be using that method.
However some methods that throw an exception do not require me to catch it like:
int num = Long.parseInt(sampleString);
Can anybody shed some light please?
There are two types of exceptions in Java: checked and unchecked. The former needs to be
catched while the latter does not. An uncheckedExceptionis a class that extends eitherRuntimeException,Error, or one of their subclasses.Long#parseLongthrows aNumberFormatExceptionwhich IS-ARuntimeException. Thus, it’s an unchecked exception and does not need to be caught.References: