String Data Type

Anything inside a Single Quotes ( ‘ ‘ ) is known as String.

Index of String:

Salesforce String Data Type

The first character of the string stores at 0th index, second character stores at 1st index, and so on.

Example:

Output:

Salesforce String Data Type

Example:  

Output:

Salesforce String Data Type

Example:  

Output:

Salesforce String Data Type

In the above example, the capitalize method capitalizes the first character of the string.

Example:  Comparing three values

Output:

Salesforce String Data Type

Example:

Output:

Salesforce String Data Type

Example:

Output:

Salesforce String Data Type

In the above example, the 1st result returns false because the case (str1 and str2) doesn`t match, and the 2nd result returns true because both the cases are same.

Example: String in Uppercase

Output:

Salesforce String Data Type

In the above example, the toUpperCase is used to return a String in uppercase.

Example: String in Lowercase

Output:

Salesforce String Data Type

In the above example, the toLowerCase is used to return a String in lowercase.

Example: Concatenating two strings

Output:

Salesforce String Data Type

Example:

Output:

Salesforce String Data Type

In the above example, we are storing the concatenation of two strings (word1 and word2) into another string (final), and then we are displaying the value (final).

Example:  Contain method

Output:

Salesforce String Data Type

Example: Contain method

Output:

Salesforce String Data Type

Example: Contain method

Output:

Salesforce String Data Type

In the above example, contains method checks if a String contains the given character is present in the string or not. If yes, then it will return true else false.

Pin It on Pinterest

Share This