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

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024
  • 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

ความคิดเห็น • 2

  • @Shomnath_Das
    @Shomnath_Das 8 หลายเดือนก่อน +1

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

  • @itelectriciian
    @itelectriciian 9 หลายเดือนก่อน

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