What is meant by immutable?

后端 未结 17 1959
天命终不由人
天命终不由人 2020-11-22 02:27

This could be the dumbest question ever asked but I think it is quite confusing for a Java newbie.

  1. Can somebody clarify what is meant by immutable? <
17条回答
  •  天命终不由人
    2020-11-22 03:19

    I really like the explaination from SCJP Sun Certified Programmer for Java 5 Study Guide.

    To make Java more memory efficient, the JVM sets aside a special area of memory called the "String constant pool." When the compiler encounters a String literal, it checks the pool to see if an identical String already exists. If a match is found, the reference to the new literal is directed to the existing String, and no new String literal object is created.

提交回复
热议问题