What is difference between StringUtils.isEmpty and StringUtils.isNotEmpty?

There is no major difference between StringUtils.isEmpty and StringUtils.isNotEmpty. They are just reciprocal of each other.

Suppose you have a string str whose value is “” or null then :

If you use StringUtils.isEmpty(str) , it will return true

If you use StringUtils.isNotEmpty(str), it will return false

They both are used as per the conditions. Suppose in our code we need to do some task if string is not empty. Then we can directly write if(StringUtils.isNotEmpty(str)) instead of writing if(!StringUtils.isEmpty(str))

Be the first to comment

Leave a Reply

Your email address will not be published.