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
Is singleton thread safe in java?
What is difference between final and finally in java?
What are different types of states exist for a thread?
Which sorting algorithm is best in java?
How do you read and print a string in java?
How is Object Oriented Programming different from Procedure Oriented Programming?
How do you input a string in java?
What are the different tags provided in jstl?
Can we compare two strings in java?
Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx
What is the default value of local and global variables?
In java how do we copy objects?
How is it possible in java programming for two string objects with identical values not to be equal under the == operator?
can java object be locked down for exclusive use by a given thread? : Java thread
What is classes in java?