How to remove space from a string using apex in Salesforce?

deleteWhitespace() is used to remove spaces from a string in Salesforce.

For Example:

String str = 'Hello World';
system.debug(str.deleteWhitespace()); //HelloWorld

Leave a Reply