when you have a line like
String s = "java";
there are two things created. there is the actual String object, that lives on heap. then, there is the reference "s" that points to that object in memory.
My favorite analogy is a house, and a piece of paper. the house is the object. the paper is your reference.
you build the house, and write down the address on the slip of paper.
You can't change - physically alter - the house, but you can erase one address and put another one on the paper. The house is immutable, the paper is not.
so with what exact code are changing the value of a String object?
I don't understand your question here. you CANNOT change the value of a string once it is created. it's not a question of the compiler saying "Nope!!!". There is simply no method that exists that will change the string.
all the things that you might THINK change the string don't - they actually create NEW strings, leaving the old ones untouched.