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
Define packages in java?
What is a java object and java application?
Is void a type?
Why are the objects immutable in java?
Which is dependent variable?
How many bytes is a string?
What is the use of jtable?
What are different types of encoding?
How would you format a date in java? I.e. In the ddmmyyy format?
What does the “static” keyword mean? Can you override private or static method in java?
What is the reason behind using constructors and destructors?
What are the parts of a method?
What do you mean by data type?
What is multi-catch block in java?
Give us the name of the list layoutmanagers in java?