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
If an application has multiple classes in it, is it okay to have a main method in more than one class?
What is package protected in java?
Is it necessary that each try block must be followed by a catch block?
What is rmi and steps involved in developing an rmi object?
How do you achieve singleton?
Objects or references which of them gets garbage collected?
What is the difference between multiple processes and multiple threads?
Where pragma is used?
What are reference variables in java?
what is thread? : Java thread
Why stringbuilder is not thread safe in java?
What is an arraylist in java?
What is the difference between an array and an array list?
Tell some latest versions in JAVA related areas?
Is sizeof a preprocessor?