Should I create private static final String = "Some exception message" or leave it inside the code? Is there any performance issues? I have a lot of exception cases. Texts are mostly different in any particular case. Wary about performance and memory issues. Internationalization is quite possible in future recs.
No difference from performance point of view.
So, for the sake of readability, and in case you don't use the same string elsewhere - leave it inside the code.
As for internationalization - I'm opposed to the idea of i18n exceptions, but if you do so:
static final
message keys).An exception to the answers from Bozho and Thilo, IMO, is when you ARE using an exception message in more than one place. If you're going to move one message to a static final string, do so for all exceptions within that file for consistency. If one finds one exception message at the top of a file, logic would suggest that all of them might be found there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With