How to Convert Integer Data Type to String in Salesforce Apex

While working on the Account object, I created the Account ID field using the Integer data type. However, the sales team wanted to store the account ID in alphanumeric form, which was not possible with the integer data type.

I was required to convert the Integer data type to a string in Salesforce Apex. In this tutorial, I will explain how I achieved this requirement and converted the integer data type to a string using different Apex methods.

Integer Data Type in Salesforce Apex

In Salesforce, Integer data type variables can store positive and negative numeric values. It is used to store short numbers or non-fractional values, which can be stored within the -2117483648 to +2117483647 range.

This data type has another subtype, Long. The extended data type is used to store more extended numbers, which can store values from -2^63 to +2^63-1. If you want to store big numbers, then you can use long data types.

Syntax:

integer i = 50; 
long no = 2145689464654L; // enter L as a suffix, either ca