In Java (the language upon which Apex is based) there is a difference in terms of where that String gets stored in the String literal pool. Apex simply disallows the use of the constructor so that all strings are stored in a pool. This has a variety of implications in terms of memory storage and security, which is why (I suspect) Apex only allows the latter and not the former.

Answer from Jeff Bennett on Stack Exchange
🌐
Camp Apex
campapex.org › lesson › 664273d84c647532c15828fa
Introduction to the String Class
Learn Salesforce Development and how to code in Apex. Camp Apex pairs Apex coding lessons focused on beginners with a built-in code editor and challenges. You can learn Apex step by step and write code from the start.
🌐
Salesforce Ben
salesforceben.com › home › salesforce string class: complete guide & tutorial
Salesforce String Class: Complete Guide & Tutorial | Salesforce Ben
May 15, 2025 - In this article, we will give you ... get started! Apex identifies many field types as Strings in Salesforce, including but not limited to: texts, text areas, long and rich text areas, picklists, and email fields....
🌐
NumericaIdeas
numericaideas.com › home › snippets › capitalize a string in salesforce apex
Capitalize a String In Salesforce Apex
March 9, 2024 - The Apex String class offered by Salesforce includes a bunch of useful functions to manipulate String, in case you would like the first letter of your String to be in title case you can use the capitalize function.
Find elsewhere
🌐
Cloud Intellect
cloudintellect.in › what-is-string-class-apex-in-salesforce
What is String Class Apex in Salesforce? - Cloud Intellect
December 3, 2024 - The String class apex in Salesforce is a powerful tool for developers, enabling them to effectively manipulate and manage string data. The String class offers many methods to handle any string manipulation task, from basic operations like ...
🌐
Sfconnect
sfconnect.com › articles › 1278 › common-apex-string-methods
Common Apex String Methods – SF Connect™
January 4, 2024 - endsWith(String suffix): This method checks whether the string ends with the specified suffix.
🌐
CRS Info Solutions
crsinfosolutions.com › home › complete list of string class methods apex in salesforce
Complete list of String Class Methods Apex in Salesforce
Salesforce Training
Salesforce Apex Tutorial – Chapter 6: String class in apex, this tutorial explains all the string methods in detailed. I have enrolled for Salesforce Admin and development online course at CRS info solutions. It’s really the best training i have ever taken and syllabus is highly professional
Rating: 5 ​
🌐
Salesforcefaqs
salesforcefaqs.com › salesforce-apex-string-class-methods
Salesforce Apex String Methods Explained with Examples
May 22, 2025 - It is useful when you want to break a string using specific characters or patterns, such as commas, spaces, or special symbols. For example, you have multiple contact names separated by a comma, and you want to store those names separately in the list collection in Salesforce Apex. For that, we can use the split() method. public class StringMethods { public void stringMethod() { String contactNames = 'Alice, Bob, Charlie'; List<String> nameList = contactNames.split(','); for (String name : nameList) { System.debug('Contact Name: ' + name); } } }
🌐
Medium
mrriyas.com › salesforce-yet-another-usage-of-string-format-in-apex-c82b41776284
Salesforce: Yet another usage of “String.format” in Apex. | by Mr. Riyas | Medium
May 14, 2023 - String.format is a method available on Apex’s String class, that can be used to build dynamic string apex. In some scenarios, you might wanted to build an error/warning/success message dynamically at run time.
🌐
Mytutorialrack
mytutorialrack.com › home › mastering apex string class: ultimate guide and tutorial
Mastering Apex String Class: Ultimate Guide and Tutorial
May 31, 2023 - Any class that stores characters or text values, is considered to be a String in Salesforce. As mentioned earlier, performing multiple actions on a single string is a common practice for coders.
🌐
Iqra Technology
iqratechnology.com › academy › salesforce-apex-training › apex-strings-string-methods
Apex Strings & String Methods – Iqra Technology
July 29, 2025 - ❮ Previous Next ❯ Strings in Apex A string in Apex is a sequence of characters used to represent text. Just like in C#, it’s widely used for storing and manipulating text data.
🌐
Swagger
editor.swagger.io
SwaggerEditor
You need to enable JavaScript to run this app · 5.2.1
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
Apex · Elm (via elm-format) Java · PHP · Ruby · Rust · TOML · XML · And more... prettier-js prettier.el Apheleia · espresso-prettier · Prettier Prettier⁺ · JsPrettier · vim-prettier neoformat ALE coc-prettier · JavaScriptPrettier · prettier-vscode ·
🌐
TutorialsPoint
tutorialspoint.com › apex › apex_strings.htm
Apex - Strings
String in Apex, as in any other programming language, is any set of characters with no character limit. ... String class in Salesforce has many methods.
🌐
Reddit
reddit.com › r/salesforce › can someone show me the apex class for this use case? newbie at development here
r/salesforce on Reddit: Can someone show me the apex class for this use case? Newbie at development here
January 4, 2020 -

**Create an Apex class with a method that returns an array (or list) of strings.**Create an Apex class with a method that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.

  • The Apex class must be called StringArrayTest and be in the public scope

  • The Apex class must have a public static method called generateStringArray

  • The generateStringArray method must return an array (or list) of strings

    • The method must accept an incoming Integer as a parameter, which will be used to determine the number of returned strings

    • The method must return a string value in the format Test n where n is the index of the current string in the array

🌐
Stack Overflow
stackoverflow.com › questions › 79858815 › in-salesforce-apex-is-string-class-immutable
In Salesforce Apex, Is String class Immutable - Stack Overflow
Signature public static void put(String key, Object value, Integer ttlSecs, cache.Visibility visibility, Boolean immutable)
🌐
Intellipaat
intellipaat.com › home › blog › what is apex string class in salesforce?
What is Apex String Class in the Salesforce? - Intellipaat
June 3, 2025 - Watch this Salesforce Training video and learn all about Salesforce: String Class Salesforce is basically a class variable that consists of various Apex String Methods and these particular String methods Salesforce allows Alt-text users to perform ...