Is it possible to change a String in Java

Everyone knows String object in Java is immutable. It means it is impossible to change its value after the object was created.

It was my answer to the question How can the value of string be changed? I was asked this question on a job interview.

But is it really impossible? Yes, it is… unless you use reflection. The following program demonstrates how you can change the value stored in a String object:

Read the rest of this entry »

Advertisements