Additionaly, it is easy to change "doModify" to "doUpdate", if they are defined at a single place as given in the second approach.
Originally posted by Ko Ko Naing:
The usage of Constants are pretty good, where there might be a need to change the actual value. As for the null value checking, I prefer checking the null value before doing actual operation on the variable. Otherwise, the unforgivable NullPointerException will occur.
The point is that with the constant.equals() trick, you don't have to worry about the NullPointerException, because it won't happen. You know the constant String is non-null and the String class can compare itself to a null value and return false.