Strings are immutable - that means I should never use += and only StringBuffer?

前端 未结 11 1530
醉梦人生
醉梦人生 2021-01-04 08:12

Strings are immutable, meaning, once they have been created they cannot be changed.

So, does this mean that it would take more memory if you append things with += th

11条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-04 08:56

    But the garbage collector will end up freeing the old strings once there are no references to them

提交回复
热议问题