Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All Methods of Class Throw Same Exceptions [duplicate]

Tags:

java

exception

I have a class that constructs and returns objects based on certain criteria, each method in the class throws the same exceptions and I would like to reduce the number of times I have to repeat the same:

public Foo getFoo() throws FileNotFoundException, IOException { ... }

Is there a way to declare that each method of a class throws the same set of exceptions?

like image 911
pxerk Avatar asked Oct 14 '25 15:10

pxerk


1 Answers

No there is no way to declare that all methods of particular class throws same set of Exceptions (as of jdk 1.8u5)

like image 132
jmj Avatar answered Oct 17 '25 04:10

jmj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!