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.
From the Javadoc:
isEmpty
public boolean isEmpty()
Returns true if, and only if, length() is 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With