When you say String is immutable, what do you mean by that?
Say I have String s = "Ness"
s= s+"Technologies";
What will happen? If the value gets appended, then what is
the meaning of immutable here?
Answer Posted / bln
Every time a new String objects gets created in this case,
but if assigned value is not same. If assigned, value is
same, then it points to same memory location, even if it is
another variable. For ex;
String s="Test";
String s2="Test";
Now s, s2 points to the same memory location.
| Is This Answer Correct ? | 20 Yes | 2 No |
Post New Answer View All Answers
What does arrays sort do in java?
How to reverse string in java?
What is the tradeoff between using an unordered array versus an ordered array?
What is a dynamic array in java?
Differences between external iteration and internal iteration?
What does provide mean construction?
What is the purpose of lambda expressions?
Explain garbage collection in java?
What do bitwise operators do?
Write a program to print fibonacci series
Is jdk required on each machine to run a java program?
Can you pass functions in java?
What is the difference between char and char *?
What is the java reflection api? Why it’s so important to have?
What are Normalization Rules? Define Normalization?