I dont understand why mam said that it is immutable. it is changing as integer change

i dont understand why mam said that it is immutable. it is changing as integer change.

hey @Harsh_Sonwani
Java String Pool is the special memory region where Strings are stored by the JVM . Since Strings are immutable in Java, the JVM optimizes the amount of memory allocated for them by storing only one copy of each literal String in the pool. This process is called interning:

String s1 = “Hello World” ;`

String s2 = "Hello World" ;

1 Like

@Harsh_Sonwani
Please mark your doubts as resolved in your course’s.