String POOL in java

后端 未结 4 1102
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 21:06

Java has string pool, due to which objects of string class are immutable.

But my question stands -

What was the need to make String POOL?

4条回答
  •  甜味超标
    2021-01-04 21:56

    When we compiler see's that a new String literal has to be created,it first check's the pool for an identical string,if found no new String literal is created,the existing String is referred.

提交回复
热议问题