Код: Выделить всё
public boolean verifyStringEqualsToConstant(String stringToBeCompared) {
// globally defined constant
final String CONSTANT = "foo";
if (StringUtils.isBlank(stringToBeCompared)) {
return false;
}
// approach A - is my constant equals to the value I am passing to this method?
return CONSTANT.equals(stringToBeCompared);
}
< /code>
или < /p>
public boolean verifyStringEqualsToConstant(String stringToBeCompared) {
// globally defined constant
final String CONSTANT = "foo";
if (StringUtils.isBlank(stringToBeCompared)) {
return false;
}
// approach B - is the value I am passing to this method equals to the constant?
return stringToBeCompared.equals(CONSTANT);
}
Я особенно предпочитаю подход b.>
Подробнее здесь: https://stackoverflow.com/questions/797 ... his-matter