I want to check the size of a string. If the size is greater than 255 characters, then reduce it to 252 and add three dots towards the end.
For example.
String1 = 'Suppose this is 255 characters'; String2 = 'Suppose this is more than 255 character';
I want the output value of String2 to be 'Support this is more than 255 charac...';
I tried the following but it didn't work:
if (String.size() > 255) { String3 = String2.abbreviate(255); }
String string3 = string2.abbreviate(255);will work. Note thatStringwill be interpreted as a class name in your code so will generate a compile error.abbreviatemethod does that - see its documentation.