String is a immutable objects . it means that string does
not change...........
But it will be chang.........
{
String s="kapil";
String s1="raj";
String s=s1;
then print(.......)
The String has been changed ..
how it is possible and why its called immutable objects
Answer Posted / anil kumar khichar
Immutable means the original String never get changed or
replaced by another one. You can simply concate another one
, but beware you can't replace it. Look at the following:-
{
String s="kapil";
String s1="raj";
String s=s1;
see here if you assign s1 to s ,there will you get error.
And it's not allowed here. So we can say Strings are immutable.
Thanks!
Anil
| Is This Answer Correct ? | 1 Yes | 4 No |
Post New Answer View All Answers
Are primitives objects?
Can an interface extend a class?
State two differences between C and Java.
Explain the importance of join() method in thread class?
What is the similarity between dynamic binding and linking?
Why array is used in java?
explain what is transient variable in java?
What is the purpose of interface?
Name some classes present in java.util.regex package.
What is ascii code?
Can we serialize static variables in java?
What is string pool?
What are the advantages of exception handling?
What is parse method?
What is java util concurrentmodificationexception?