Skip to main content
added 50 characters in body
Source Link
Ratan Paul
  • 22.9k
  • 14
  • 59
  • 100

The difference is slight between isEmpty()isEmpty() and isBlank()isBlank()

isBlank(inputString)isBlank(inputString): Returns true if the specified String is white space, empty (''), or null; otherwise, returns false.

isEmpty(inputString)isEmpty(inputString) : Returns true if the specified String is empty ('') or null; otherwise, returns false.

So the isEmpty()isEmpty() function is a subset of isBlank()isBlank() function.

Usage

Usage In In case, your check is for a null string or a string which does not contain any value('')value(''), but in your usecase a String having a space is valid then use isEmptyisEmpty().

If you want to check if your string is null or have no value or have only blank spaces you should use isBlank

To know more about the String class you can follow the following link : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm Documentation

Hope this helps..

The difference is slight between isEmpty() and isBlank()

isBlank(inputString): Returns true if the specified String is white space, empty (''), or null; otherwise, returns false.

isEmpty(inputString) : Returns true if the specified String is empty ('') or null; otherwise, returns false.

So the isEmpty() function is a subset of isBlank() function.

Usage In case, your check is for a null string or a string which does not contain any value(''), but in your usecase a String having a space is valid then use isEmpty.

If you want to check if your string is null or have no value or have only blank spaces you should use isBlank

To know more about the String class you can follow the following link : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm

Hope this helps..

The difference is slight between isEmpty() and isBlank()

isBlank(inputString): Returns true if the specified String is white space, empty (''), or null; otherwise, returns false.

isEmpty(inputString) : Returns true if the specified String is empty ('') or null; otherwise, returns false.

So the isEmpty() function is a subset of isBlank() function.

Usage

In case, your check is for a null string or a string which does not contain any value(''), but in your usecase a String having a space is valid then use isEmpty().

If you want to check if your string is null or have no value or have only blank spaces you should use isBlank

To know more about the String class you can follow the following link : Documentation

Hope this helps..

Source Link

The difference is slight between isEmpty() and isBlank()

isBlank(inputString): Returns true if the specified String is white space, empty (''), or null; otherwise, returns false.

isEmpty(inputString) : Returns true if the specified String is empty ('') or null; otherwise, returns false.

So the isEmpty() function is a subset of isBlank() function.

Usage In case, your check is for a null string or a string which does not contain any value(''), but in your usecase a String having a space is valid then use isEmpty.

If you want to check if your string is null or have no value or have only blank spaces you should use isBlank

To know more about the String class you can follow the following link : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm

Hope this helps..