I saw a Java article that said it’s better to use string constant in annotations (you can see the article here). Why is that a good practice?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The most obvious use would be that finding all references to the constant is easier than finding all occurrences of the string. Your IDE will immediately help you with the former, but the latter you need to do yourself.
Then, there’s also the issue of maintainability in case you need to change the value (consistently, everywhere).