+ 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