String pool is feasible solely as a result of String is immutable in Java.This way Java Runtime environment saves heap memory. String variables will be referenced to an equivalent String variable within the pool. String interning wouldn't be possible as a result of if any variable would have modified the worth, it might be mirrored within the different variables too.
If String isn't immutable then it might cause a severe security threat to the applying Object; for instance, information username, Password are passed as String to urge information affiliation and in socket programming host and port details and could alter the string object. Since String immutable, its worth can’t be modified otherwise any hacker might amendment the documented worth to cause security problems within the application.
Since String are immutable, it's safe for multi threading process and task . A single String instance can be shared across completely different threads. This avoids the process of synchronization for thread safety. Strings are implicitly thread-safe.
Strings are utilized in java category loader and immutability of String provides security that correct class is obtaining loaded by Class Loader. For instance, consider associate degree instance wherever you're making an attempt to load SQL data from java.sql.Connection category however the documented can be modified to hacked.Connection category which can be altered or unauthenticated access to data and can lead to data breach .
As String is immutable, when the string is created or intantiated it generates its hashcode and so it saves computation of the string object again.