How to concatenate as string in Salesforce?

How to concatenate as string in Salesforce?

There is no specific method in Salesforce Apex for String Concatenation. We can use plus(+) operator for string concatenation. Please check the sample code where two integers are converted to String values and then concatenated using String.valueOf() method.

Sample Code:

String Str = '';
Integer Val1 = 123;
Integer Val2 = 456;
Str = String.valueOf( Val1 ) + String.valueOf( Val2 );
System.debug( 'Concatenated String is ' + Str ); 

Leave a Reply