This course is currently a work in progress. Please join the waitlist to receive regular updates.
Find the length of string in apex
In apex, the length()
method returns the length of a given string. This method is used to validate the string length to prevent saving records that exceed certain limits.
Following is an example of finding the length of a string in apex:
Loading...
In the above example:
- In the above example,
inputString
, is a string variable with the default value 'Hello World'. - The
length()
method is used to find the length of the string. - The string
length()
function returns an integer number, the length of the string.
Try It Yourself
Loading...