Why Strings are immutable in JAVA? | Core JAVA| most asked Interview Questions| Freshers Experienced

preview_player
Показать описание
The String is immutable in Java because of the security, synchronization and concurrency, caching, and class loading. The reason of making string final is to destroy the immutability and to not allow others to extend it. The String objects are cached in the String pool, and it makes the String immutable
Рекомендации по теме
Комментарии
Автор

String is immutable this feature is applicable for not consuming unnecessary space or memory in JVM by creating same string again and again

Shomnath_Das
Автор

class HelloWorld {
public static void main(String[] args) {
String str="Hello World";
str=str.replaceAll(" ", "");
System.out.println(str);
}
}
Explain this bro

kannansm