- I am using these both methods to get the message thrown by the catch block while performing error handling
- Both of them get me the message from the error handling but what exactly does these two differ with
- I did some searching from internet and came up with this answer from here
Java Exceptions inherit their getMessage and getLocalizedMessage methods from Throwable (see the related link). The difference is that subclasses should override getLocalizedMessage to provide a locale-specific message. For example, imaging that you're adapting code from an American-English speaking company/group to a British-English group. You may want to create custom Exception classes which override the getLocalizedMessage to correct spelling and grammer to what the users and developers who will be using your code might expect. This can also be used for actual translations of Exception messages.
Questions::
Does that mean
language specific
implementations ? like if i usee.getLocalizedMessage()
for example my app inEnglish
- error will be thrown inEnglish
, if i use my app inSpanish
- then error will be thrown inSpanish
Need some clear explanation on where and when i can use these methods to my use