How to remove space from a string in Salesforce?

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

Sample Code:

String str = 'Hello Hi';
system.debug(str.deleteWhitespace()); //HelloHi

2 comments:

  1. Why is this method not in the official string class documentation?

    ReplyDelete
    Replies
    1. Check this
      https://developer.salesforce.com/releases/release/Winter13/New+String+Methods

      Cheers!!!

      Delete