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 / ramaraju

hi

String is a Immutable object,that is
string is an object not a datatype variable.

From the above example

String s=s1 //means it will create a new objet s with the
value raj,not change the value.

Note:whenever u edit or concatinate the string internally
it will create a new object,but not chang that object.

Is This Answer Correct ?    16 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can any body body expalin best definitions & best real time exaples for opps concepts.

1840


What does this () mean in java?

545


Which sorting is best in java?

536


How does a cookie work in Servlets?

351


What is the difference between static and global variables and also define what are volatile variables?

552






Can we use both this () and super () in a constructor?

556


What is Garbage Collection in Java

611


Is 9 a prime number?

470


When to use runnable interface vs thread class in java?

525


What is ++ a in java?

570


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread

598


How many bytes is 255 characters?

553


What is static import in java?

534


What is the difference between math floor and math round?

503


What is private protected in java?

550