r/javahelp • u/Ok-Dealer-3051 • Mar 17 '26
why some exception need catch some not?
im a noobied in java recently i wondering why some throws-exception method like File#createNewFile() need a catch block but Interger.parseInt(String) no need a catch block. could any body anwser it?
5
Upvotes
View all comments
Show parent comment
1
u/vu47 Mar 17 '26
I'm well aware. :-) This is my 30th year using Java.
Personally, I'm not really a big fan of exception throwing at all: I'd rather have Either or something similar. I've largely switched to Kotlin at this point, wrap exceptions, and return them. Exceptions are a side effect, and I aim to program as functionally as possible in Kotlin within the limitations it has.