As I know if method throws an exception Java compiler forces the caller of that method to catch that exception.
I see that parseInt
throws NumberFormatException
:
public static int parseInt(String s) throws NumberFormatException {
return parseInt(s,10);
So why I can call it wthout catching the exception :
String str = "5";
int n = Integer.parseInt(str);