Search Interview Questions
| More than 3000 questions in repository.|
There are more than 900 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Java - Interview Questions and Answers|
|Ans. Because it doesn't make the change in the existing string but would create a new string by concatenating the new string to previous string. So Original string won't get changed but a new string will be created. That is why when we say|
It means nothing because we haven't specified the reference to the new string and we have no way to access the new concatenated string. Accessing str1 with the above code will still give the original string.
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  string  string immutable  immutability  string concat|
|Why is String immutable in Java ?|
|How does making string as immutable helps with securing information ? How does String Pool pose a security threat ?|
|Why shouldn't we use string concatenation extensively or in a loop ?|