Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
The key benefits of keeping strings as immutable are caching, security, synchronization, and performance. The String is the most widely used data structure. Caching the String literals and reusing them saves a lot of heap space because different String variables refer to the same object in the String pool. It is also more secure, since they wont be modified.
7th Apr 2020, 3:41 AM
Fernando Pozzetti
Fernando Pozzetti - avatar