Of course not. Do you really think "" is not clear enough ?
Constants have essentially 3 use cases:
- Document the meaning of a value (with constant name + javadoc)
- Synchronize clients on a common value.
- Provide a shortcut to a special value to avoid some init costs
None apply here.
Answer from David Pierre on Stack Overflowpublic String getNameTierart() {
return nameTierart;
}
// Tiere deklarieren und initalisieren
Affe affe = new Affe();
affe.setNameTierart("Affe");So if affe.setNameTier("") for example the program should insert "unknown" automatically .
So I guess
check if string is empty if so print unknown
else print value
is there a check empty command?
thanks in advance.
java - Is StringUtils.EMPTY recommended? - Stack Overflow
How To Create an Empty String
In Java, should I use (String ) isEmpty() or isBlank() when checking an XML object for an empty value?
Shorter (efficient) way to check if a string is null or empty?
Of course not. Do you really think "" is not clear enough ?
Constants have essentially 3 use cases:
- Document the meaning of a value (with constant name + javadoc)
- Synchronize clients on a common value.
- Provide a shortcut to a special value to avoid some init costs
None apply here.
I use StringUtils.EMPTY, for hiding the literal and also to express that return StringUtils.EMPTY was fully expected and there should return an empty string, "" can lead to the assumption that "" can be easily changed into something else and that this was maybe only a mistake. I think the EMPTY is more expressive.