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


Please Help Members By Posting Answers For Below Questions

What is slash r?

538


Is java platform independent?

563


What is the role of the java.rmi.naming class?

517


Explain the public class modifier?

497


Explain the importance of finalize() method.

560






What is ternary operator in java?

589


What is the console in java?

672


When will you define a method as static in Java?

562


Explain throw keyword in java?

607


describe synchronization in respect to multithreading? : Java thread

498


What is procedure writing?

507


What is the use of coding?

517


what is singleton class in java?

617


Name the components that are termed to be Heavy-weight component but available in Light-weight components?

1980


In which language java is written?

535