What is the difference between these two methods?
public boolean nameControl(String str)
{
if (str.trim().isEmpty()) return false;
if (str.trim().length() == 0) return false;
return true;
}
I need find out that str
should have at least one character.
There is no real difference between them.
Javadocs for isEmpty()
Returns true if, and only if, length() is 0.