Hello,

This is my first post, so if I did something wrong, please don't chew me up .

Anyways, I'm writing an application for school, and I wanted to put in some error messages in case the user enters an invalid input, does something wrong, etc. I was thinking of just printing the error message in the following fashion:

ex.:
JOptionPane.showMessageDialog(null, "You made this mistake"...);

However, I was wondering if there is a better way to store the error messages, such that I could have access to all the error messages in my program in one place, and when I want to use a specific message, I just need to refer to that place in order to use it. I was thinking of making a static class full of strings, and referring the code to that class, i.e.:

static class ErrorMessages
{
 final String INVALID_NUMBER = "Invalid input. Please make sure the text consists only of numbers;
 
final String ERROR_1 = "Blah blah blah";
 
final String...
}

and in my classes, do

JOptionPane.showMessageDialog(null, ErrorMessages.ERROR_1,...);

Thanks in advance!