To check whether a String is null or empty or blank using Apex in Salesforce, we can use the following methods
Sample Code:
String var = 'abc';
if(String.isNotBlank(var)) {
//The string is not empty or blank or null
}
else {
//The string is empty or blank or null
}
Cheers!!!
isBlank
|
Returns true if the specified
String is white space, empty (''), or null; otherwise, returns false.
|
Returns true if the specified
String is empty ('') or null; otherwise, returns false.
|
|
Returns true if the specified
String is not whitespace, not empty (''), and not null; otherwise, returns false.
|
|
Returns true if the specified
String is not empty ('') and not null; otherwise, returns false.
|
Sample Code:
String var = 'abc';
if(String.isNotBlank(var)) {
//The string is not empty or blank or null
}
else {
//The string is empty or blank or null
}
Cheers!!!
thank you
ReplyDelete