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
Can I learn java in 3 months?
How to reverse a string in java?
Variable of the boolean type is automatically initialized as?
Explain about fail safe iterators in java?
What is a native method in java programming?
What is the difference between hashmap and hashtable in java?
What is a parameter used for?
Which collection allows duplicate values in java?
What is equals method in java?
Explain thread in java?
Can we declare array without size in java?
How do you add an element to a set in java?
Explain about core java?
When do I need to use reflection feature in java?
What does || mean in vectors?