Page 1

1) Since String is immutable it can safely share between many threads, by which we can have multithreaded programming. 2) We can store string in string pool for example as below.If it not mutable then it would not be possible. 3) String immutability allows to cache its hash value which greatly improves String performance in Hash based collections. 4) Better memory management – String s1=”hello world”; String s2=”hello world”; JVM automatically points both s1 and s2 to the same address in the heap memory. This should decrease the usage of memory when dealing with a large number of Strings in your program. 5) Helps

bue angels  

bjhyhzdhkhfdzsiyfiydfn huiyi8y

Read more
Read more
Similar to
Popular now
Just for you