Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Gail Knight   on Jun 14 In Java Category.

  
Question Answered By: Eloise Lawrence   on Jun 14

String is an inmutable object, so its contents
cannot be changed. When you do the following:

String s = "a";
s = s + "b";

is the same that

s = new String(s + "b");

So, the first object  is not referenced anymore, and
will be cleaned by the garbage collector.

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on String Object Or get search suggestion and latest updates.


Tagged: